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
Added ImageSequence all_frames #3778
Conversation
hmmm.... Maybe add multi-threading support? If no time for this, then you could just silently add the third parameter anyway, so that future code is backwards compatible with the first version of the function. |
While we are concerned with backwards compatibility, I don't think that we are concerned with forwards compatibility. Nothing else in the Pillow runtime uses multiprocessing, so I'm not personally inclined to integrate it here. If anyone else feels otherwise, feel free to comment. Multiprocessing can't be applied to the process of splitting up a single image into frames, because it uses the same file pointer, but it could be applied to the supplied function. If a user wanted to do that, they could just - from PIL import Image, ImageSequence
im = Image.open('Tests/images/iss634.gif')
ims = ImageSequence.all_frames(im)
from multiprocessing import Pool
def f(im_frame):
return im_frame.rotate(180)
ims = Pool(5).map(f, ims)
ims[0].save('out.gif', save_all=True, append_images=ims[1:]) |
but isn't this a special case? You are basically processing multiple images at once. And it seems it would be used frequently IMHO. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add release notes.
Co-Authored-By: Hugo <hugovk@users.noreply.github.com>
Resolves #3758
Adds a new method to apply a supplied function to all frames of an image at once. So, for example,