Image processing using indexed colors profiles

In order to achieve light web pages, it’s good to use images with indexed color profiles AND small pixel size. The problem is that the resize_image function looses the color index of the original image, leading to an image heavier than the original. See this example:

duniter-logo ae63c8b0dfd9c51a00 ae63c8b0dfd9c51a00_

Image 1 is 250x250 pixels and weights 14.8 kB
Image 2 is produced with resize image, is 160x160 pixels and weights 27.4 kB
Image 3 is created using GIMP’s color index applied on image 2 and is 160x160 pixels and weights 5.1 kB

We can see here that:

  1. the resized image is 1.8x heavier than the original despite having 2.4x less pixels
  2. we can produce a same-sized image 5.4x lighter using indexed color profiles

@keats, a quick fix in mind?

PS: for people who do not know indexed color profiles, see

Hmm we do use the image crate, I would need to check their docs to see if we’re doing something wrong.

1 Like

It seems not to be supported yet :