Support for Multiframe GIFs with Variable Frame Dimensions
Feature description
GIF images are typically multiframe, with the first frame having full dimensions (HxW) and subsequent frames containing partial data (h1xw1, h2xw2, h3xw3, etc.) that replace portions of the previous frame based on the disposal method, where h1, h2, h3, … < H and w1, w2, w3, … < W.
Currently, GDAL reads only those frames in multiframe GIFs that have the same dimensions as the first frame. It does not process frames with different dimensions compared to the first frame. This limitation is evident in the source code: https://github.com/OSGeo/gdal/blob/master/frmts/gif/gifdataset.cpp (search for “hGifFile->ImageCount” using Ctrl+F).
Additional context
Consider two GIFs:
- sample1.gif: 3 frames, all with dimensions 306x480.
- sample2.gif: 24 frames, with the dimensions as - first frame: 1080x1080, second frame: 426x828, third frame: 432x830, fourth frame: 433x824, and so on.
GDAL successfully reads all three frames in sample1.gif. However, for sample2.gif, it reads only the first frame due to the constraint in the source code that requires uniform frame dimensions.
sample1.gif:
sample2.gif:
This seems to be somewhere between wont fix and low priority to me, unless there's a clear need for that in a geospatial context. I guess more generic purposes imaging toolkits would be better for such kind of task