Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ImageSequence.pyi #11625

Merged
merged 2 commits into from
Mar 23, 2024
Merged

Update ImageSequence.pyi #11625

merged 2 commits into from
Mar 23, 2024

Conversation

ViktorSky
Copy link
Contributor

Updating stubs for the PIL.ImageSequence module

This module is used to extract the frames from an Image object, but currently it gives a type error for not having annotation.
In version 10.2.0 pillow is already included with annotations for this module, but it is hidden by _typesheed

here I leave the reason for the pull

from typing import BinaryIO
from PIL import Image, ImageSequence
from io import BytesIO

def resize_gif(file: str | BinaryIO, size: tuple[int, int], mode: str | None = None) -> BytesIO:
    gif = Image.open(file)
    frames: list[Image.Image] = []
    for frame in ImageSequence.all_frames(gif):
        if mode:
            frame = frame.convert(mode)
        frames.append(frame.resize(size))
    image, *frames = frames
    result = BytesIO()
    image.save(result, save_all=True, append_images=frames, duration=gif.info["duration"], loop=gif.info["loop"])
    return result

This comment has been minimized.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@srittau srittau merged commit f337eb8 into python:main Mar 23, 2024
43 checks passed
@ViktorSky ViktorSky deleted the patch-1 branch March 26, 2024 02:42
@ViktorSky ViktorSky restored the patch-1 branch March 26, 2024 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants