in reply to How to keep Imager's image files small ?

My thoughts were to make it a simple 16 colors (not 16 bits) images

In general, there are no such things as 16-color images.

The closest you'll get is palettised images which use 8 bits per index (3-bits each for red & green and 2-bits for blue) giving a 256 colors in total.

Of course, you do not need to use all 256 palette entries. If you only use 16 colors, then the size of the palette stored in the image file will (sometimes) be reduced(*), but the image will still require 1-byte per pixel to store the indexes, so the gain of going below 256 colors is minimal(**).

(*From approximated 4*256=1024 bytes for 256 entries; to 4*16=64 bytes for 16 entries. Not all image tools do this.)

(**There is the possibility that using a palettised .png that only uses 16 colors might compress more easily thereby further reducing the size of the image file.)


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

  • Comment on Re: How to keep Imager's image files small ?

Replies are listed 'Best First'.
Re^2: How to keep Imager's image files small ?
by Corion (Patriarch) on Jul 27, 2012 at 20:38 UTC

    It seems that Imager supports dithering. At least Imager::ImageTypes mentions "Floyd Steinberg error diffusion", which seems to suggest that it can be used to further reduce the number of used colours at the cost of image resolution.

      I think you'll find that once you write the images to disk in any of the popular (gif/jpg/png) formats, they'll be stored as 8-bit indexed palletised images.

      The tiff file format might theoretically support 4-bit indexes; but I've never come across one; nor any tool that would write one?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

        You'd be wrong.

        Imager can write to bmp, png, tif, ico at 4 bits per pixel, though png was only added to that list in Imager 0.90 (April 2012).

        GIF is a special case - if the stored palette is 4 bits (16 colors) then it will start compression with a 5 bit code size, there's none of the packing 2 indices per byte as for the other formats.