1

Using Gimp, I reduced an image to 4-colors indexed mode.

I actually need only 3 colors: black, blue and white/background, but due to the 2^n constraint I went for black, white and 2 shades of blue.

I did that in order to reduce file size as much as possible.

Now the question is what is the best lossless format to save this file in, that results in minimal file size?

Again - I'm using Gimp.

Edit:

Especially, I'd be glad to find a file format that takes advantage of this reduced color depth. I assume that PNG and GIF, being general formats, do not take advantage of it. Am I wrong?

1
  • 1
    Both PNG and GIF support 2 color and 4 color palettes, but I think that the pixel sample data is still a full byte in size, at least, before they apply compression. PNG supports "pre-compression filtering" which are a set of reversible (lossless) methods to make the data more repetitive and therefore more compressible. Large rows of identical palette index references are very compressible.
    – Yorik
    Commented Oct 28, 2016 at 17:37

2 Answers 2

3

GIF and PNG are both lossless, the 'best' format to use will depend on the actual content of your graphics. Different styles of illustration and levels of detail will compress differently. Try both and see how you get on.

Speed of decompression may be an issue, especially for web use. Again, you may need to experiment. There is a good article about PNG compression here: http://www.howtogeek.com/203979/is-the-png-format-lossless-since-it-has-a-compression-parameter/

1
  • Is there any advantage in making the image 2 bit indexed with png, or the png ignores that advantage, rendering that reduction of size useless?
    – Tar
    Commented Oct 28, 2016 at 14:52
2

Lossy format exist due to either large color information or large pixel quantity, or both.

JPEG for example, compresses most of the color information in clusters so it shrinks the file size in sacrifice of quality.

If you have just 4 colors in your index, you can achieve a very tiny file size with either PNG or GIF, since both can rely on indexes to reduce their sizes.

Which one may depend on your purpose, for really fast loading, GIF would be your guy. But if you want optimize file size, PNG has compression and will save further bits, but it will demand you some microseconds to decompress it, what shouldn't be an issue.

Your Answer

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

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