Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

sg3-141-592
Copy link

There are errors loading animated gifs where the frame disposal method is set to DISPOSAL_UNSPECIFIED #9009

This is because when an animated gif has disposal mode DISPOSAL_UNSPECIFIED, decode_gif is defaulting to "background" drawing mode. It needs to be DISPOSE_DO_NOT instead where changes are overwritten onto the previous canvas. This is the default behaviour of web browsers and libraries like Pillow - GifImagePlugin.py.

After this the example gif subsequent frames display correctly

import cv2
import torchvision

gif = torchvision.io.read_image('jake.gif').numpy().transpose(0, 2, 3, 1)
image = cv2.cvtColor(gif[5], cv2.COLOR_RGB2BGR)
cv2.imshow(f'Frame 5', image)
cv2.waitKey()
image

…posal mode DISPOSAL_UNSPECIFIED or DISPOSAL_PREVIOUS. This fixes loading animated gifs with these modes set
Copy link

pytorch-bot bot commented Oct 11, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9241

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

Copy link

meta-cla bot commented Oct 11, 2025

Hi @sg3-141-592!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@sg3-141-592 sg3-141-592 marked this pull request as draft October 11, 2025 10:59
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.

1 participant