-1

I have milions of .PNG images which all have same colors. I would like to use this knowledge in order to save some space in following manner: Force all files to use same palette and store only IHDR and IDAT section and use same PLTE for all files. I would then inject PLTE when image is requested. As this is not trivial i am asking is this is sound approach? Is there some obstacle that i missed? Is there another approach for this problem? Initial observation is that this would save ~15% of storage.

Examle how much space is saved for single image if PLTE section is not storred:

enter image description here

watbywbarif
  • 6,487
  • 8
  • 50
  • 64

2 Answers2

1

Encode your images in grayscale format (instead of pal indexed). Keep your palette in single separate file.

On image request change fromat back to indexed palette and inject palette entries.

Anonymous
  • 2,122
  • 19
  • 26
1

That looks a cost too high (developing a software to store and rebuild invalid PNG files) to gain too little. It sounds also strange that you have "millions" of images with the "same colours" - what does the later mean? do they really have the same palette (up to 256 colors)? If to "force a common palette" you have to sacrifice quality, wouldn't be more efficient to store them in JPEG.

Also, the images must be quite small if stripping the palette gives you 15% of gain. In that case, a more practical approach (especially if the files have the same size, in pixels) would be to store groups of them tiled together in a single PNG image, similar as CSS sprites.

leonbloy
  • 73,180
  • 20
  • 142
  • 190