Pillow icon indicating copy to clipboard operation
Pillow copied to clipboard

Use maximum frame size in IHDR chunk when saving APNG images

Open radarhere opened this issue 1 year ago • 0 comments

https://github.com/python-pillow/Pillow/issues/1138#issuecomment-1955716795 reported an image that img.show() did not successfully open.

Images are temporarily saved as PNGs when used with show(). The image has two frames of different sizes, and investigating, I found that https://wiki.mozilla.org/APNG_Specification states

The boundaries of the entire animation are specified by the width and height parameters of the PNG IHDR chunk

and

each frame's region (x,y,width,height) must lie completely within the parent PNG canvas

This PR expands the size in the IHDR chunk to the maximum size of all of the frames, and that fixes the problem.

radarhere avatar Feb 21 '24 08:02 radarhere