File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
torchvision/csrc/io/image/cpu Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -122,11 +122,16 @@ torch::Tensor decode_gif(const torch::Tensor& encoded_data) {
122122 // - the current image is smaller than the canvas, hence exposing its pixels
123123 // The "background" disposal method means that the current canvas should be
124124 // set to the background color.
125- // We only support these 2 modes and default to "background" when the
126- // disposal method is unspecified, or when it's set to " DISPOSE_PREVIOUS"
125+ // We only support these 2 modes and default to DISPOSE_DO_NOT when the
126+ // disposal method is unspecified, or when it's set to DISPOSE_PREVIOUS
127127 // which according to GIFLIB is not widely supported.
128128 // (https://giflib.sourceforge.net/whatsinagif/animation_and_transparency.html).
129- if (i > 0 && gcb.DisposalMode == DISPOSE_DO_NOT) {
129+ // This is consistent with default behaviour in the majority of web browsers
130+ // and image libraries like Pillow.
131+ if (i > 0 &&
132+ (gcb.DisposalMode == DISPOSAL_UNSPECIFIED ||
133+ gcb.DisposalMode == DISPOSE_DO_NOT ||
134+ gcb.DisposalMode == DISPOSE_PREVIOUS)) {
130135 out[i] = out[i - 1 ];
131136 } else {
132137 // Background. If bg wasn't defined, it will be (0, 0, 0)
You can’t perform that action at this time.
0 commit comments