I create a GIF in FFmpeg using a custom color palette. Since custom color palette significantly reduces the size of the GIF I want to keep it as restricted as possible.

The GIF I'm trying to convert has white and two shades of blue. I assume there are also transitional colors, like a mix of white and blue to make the logo smoother on the edges. I don't know how many colors in the palette I need to create a good looking GIF.

Is there a way to calculate color palette size based on main colors?

Here are two GIFs for comparison with 8 and 16 color palette accordingly. Can someone explain why 8 colors produces dithering, distorts colors and 16 does not?

8 color palette GIF

16 color palette GIF


The biggest reduction you can make in a gif size is reducing the number of frames and modifying the playing time of each.

  • Your original gif has more than 420 frames, many of them repeated
  • The size is approximately 290kb

  • This gif has 160 frames
  • Size: 139 kb

enter image description here

enter image description here

  • Thank you for your answer, but I'm interested in color palettes. I know that decreasing FPS will decrease the size. I made it as low as possible to preserve the smoothness of the animation, if it gets below 23 FPS - it looks laggy. – Peter May 30 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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