Skip to content

If append_images is populated, default save_all to True #8781

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

Merged
merged 2 commits into from
Mar 27, 2025

Conversation

radarhere
Copy link
Member

#8775 (comment) requests that save_all default to true if append_images is not empty.

So rather than requiring save_all in the tutorial example,

from PIL import Image

# List of image filenames
image_filenames = [
    "hopper.jpg",
    "rotated_hopper_270.jpg",
    "rotated_hopper_180.jpg",
    "rotated_hopper_90.jpg",
]

# Open images and create a list
images = [Image.open(filename) for filename in image_filenames]

# Save the images as an animated GIF
images[0].save(
    "animated_hopper.gif",
    save_all=True,
    append_images=images[1:],
    duration=500,  # duration of each frame in milliseconds
    loop=0,  # loop forever
)

users can just

images[0].save(
    "animated_hopper.gif",
    append_images=images[1:],
    duration=500,  # duration of each frame in milliseconds
    loop=0,  # loop forever
)

Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

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

Please could you resolve the conflict?

@hugovk hugovk merged commit 10ccbd7 into python-pillow:main Mar 27, 2025
55 checks passed
@radarhere radarhere deleted the append_images branch March 27, 2025 21:09
radarhere added a commit to radarhere/Pillow that referenced this pull request Mar 29, 2025
radarhere added a commit to radarhere/Pillow that referenced this pull request Mar 29, 2025
hugovk pushed a commit that referenced this pull request Mar 29, 2025
Co-authored-by: Andrew Murray <radarhere@users.noreply.github.com>
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.

2 participants