Skip to content

Conversation

@sg3-141-592
Copy link
Contributor

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
@pytorch-bot
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:

✅ No Failures

As of commit a3054dc with merge base f5c6c2e (image):
💚 Looks good so far! There are no failures yet. 💚

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

@meta-cla
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 cla@meta.com. Thanks!

@sg3-141-592 sg3-141-592 marked this pull request as draft October 11, 2025 10:59
@AntoineSimoulin
Copy link
Member

@sg3-141-592 thanks for putting this fix together! This is looking good. I only adjusted the linting. Feel free to fill the Contributor License Agreement and submit the PR for review!

@sg3-141-592
Copy link
Contributor Author

@sg3-141-592 thanks for putting this fix together! This is looking good. I only adjusted the linting. Feel free to fill the Contributor License Agreement and submit the PR for review!

Sure CLA check should clear in the next hour

@sg3-141-592 sg3-141-592 marked this pull request as ready for review October 14, 2025 14:30
@meta-cla meta-cla bot added the cla signed label Oct 14, 2025
@meta-cla
Copy link

meta-cla bot commented Oct 14, 2025

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@AntoineSimoulin AntoineSimoulin merged commit faffd5c into pytorch:main Oct 14, 2025
59 checks passed
@github-actions
Copy link

Hey @AntoineSimoulin!

You merged this PR, but no labels were added.
The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants