: Do all gif files only store changing pixels? I opened a Gif file in GIMP, and noticed that only the pixels that changed from frame to frame are actually saved in each frame. I read various
I opened a Gif file in GIMP, and noticed that only the pixels that changed from frame to frame are actually saved in each frame. I read various explanations of the file format, and none of them mentioned storing only changing pixels (or they did, but used technical language I didn't understand). Do all Gifs work like this, or do only some of them do? If only some, is there a way to tell based on the bits in the file?
More posts by @Shanna688
3 Comments
Sorted by latest first Latest Oldest Best
Only some of them do. It's an optimization method used to reduce file size.
I'm not entirely sure how to tell if a GIF is using this technique without some kind of analysis of each frame, because essentially it's just transparent background in some frames, and any GIF can have transparent parts, even if it's not optimized with this technique. There are no special markings for these GIFs.
But you can use ImageMagick convert command with -coalesce option to remove this optimization and redraw each frame completely, if you want. It will increase file size, but may be useful if your intention is to edit these GIFs.
www.imagemagick.org/script/command-line-options.php#coalesce
They all work that way. GIF has always been capable of storing multiple images for compositing, even before "animation" was introduced.
The header of the image specifies a canvas size, and each image (image descriptor) in the file is marked by a hex value (2C). Following that separator is a set of values to mark the extents of the image. That is: top position, left position, width, height. Each frame is an "image descriptor," and so the extents of any one image descriptor is arbitrary.
This is useful because it is a form of compression in that it can omit a large amount of the image. But also, the rectangle described must encompass all changed pixels. The best case is a single pixel, the worst case is a two-pixel change where one pixel is at the canvas origin, the other pixel is at the canvas width and height.
GIF frames that are the simply whole extents of the canvas (unchecking the check box described in rafael's answer) are a special case where the top and left are the canvas origin and the width and height are the canvas size.
Some aplications do save all the frame, and some others just save the diference between the current frame and the previous one. (Actually it is a rectangular zone, not individual pixels)
This is a screen capture of Corel PhotoPaint. The last checkbox is to save only the diferences or the full frame.
But telling that based only on the bits of an image would be difficult. I supose it is better simply to open the gif in a suitable program.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.