2

I'm looking into various file formats and how they are optimized for their main purposes, but I've found that the GIF file format uses lossless compression meaning it would have a higher file size which wouldn't be desirable for its common use online so I was wondering if the GIF file format removed data which is shared between frames like a common background in order to reduce the file size and still have decent image quality.

If it doesn't could you explain why the GIF file format doesn't use lossy compression or doesn't share data between frames because it is generally used online where low storage space is really needed?

1
  • 1
    Be aware that while the compression in a GIF may not be lossy like a JPG, the creation of a GIF is. When you create a GIF image, the gamut, dithering, transparency channel, and number of colors are all susceptible to changing, depending on your settings.
    – 13ruce
    Apr 18, 2019 at 14:10

2 Answers 2

2

I was wondering if the GIF file format removed data which is shared between frames like a common background

Yes. But depends on the application that makes it.

Depending on the application you are using there are some options.

  • Maintain the previous frame
  • Save as a frame only the changing part. This is a bit relative because it is not pixel by pixel basis, but a rectangle that contains all the changing part.

enter image description here

When these two options are combined, you can maintain your background and save some bytes.

To optimize a GIF avoid using any dither. One changing pixel on the opposite side of the animation will cause to save a large section.

doesn't use lossy compression

This is relative...

If your image is already an 8-bit file with a 256 color palette, yes, the saving will be lossless.

But if you start with a 24-bit image, like a photo, the conversion to 8 bit will be massive destruction of data.

Actually, you can think to save a GIF as a two-step process.

  • Converting the image to a fixed palette.
  • Saving the image.

The step where you lose the information is in step 1.

1
  • Sorry for taking so long to respond. I read your message earlier but hadn't had the chance to respond. Thank you so much for your help. This was very clearly presented and easy to understand for someone new to this field. Thanks again. +1
    – Pi Net
    Apr 23, 2019 at 16:01
2

GIF compression is primarily in the colour table, rather than the image pixels - subsetting to a decreased total gamut and (depending upon export settings) can subset further to include definitions only for colours present in the pixels of the image itself; many GIF export compression algorithms do parse through an animated GIF, spot repeated pixels and omit them from later images in a sequence, but that’s not inherent to the GIF format - it supports that method, but it happens during encoding only if the encoder you’re using has that feature.

1
  • This is really interesting, but not presented in a way which is easy to understand for people new to the field, but thanks for the answer anyways :)
    – Pi Net
    Apr 23, 2019 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.