document-policy icon indicating copy to clipboard operation
document-policy copied to clipboard

Optimized image policy -- image-compression -- what is the best default compression ratio to set to

Open loonybear opened this issue 7 years ago • 5 comments

For details of the policy, see the explainer. Current the policy sets the default compression-ratio to be 10.

I did some research on images on the web (randomly selected images, compressed images, compute byte-per-pixel ratio): Compressed JPEG: 0.4 Compressed PNG: 0.76 JPEG: 0.88 PNG: 2.4

So setting it to 10 is definitely not sufficient enough.

So should we set different compression restriction on different image types, if so, on which types? Or should we change the default ratio (currently 10) to something more strict such as 1 or 2? But this might not work great on GIFs since animated GIFs can have multiple frames and the file size could be bigger.

The default ratio can still be override by list value.

loonybear avatar Aug 14 '18 14:08 loonybear

@clelland @dbaron @travisleithead @hober @jpchase @ojanvafai

loonybear avatar Aug 14 '18 14:08 loonybear

The initial default policy of 10 represents bits-per-pixel, rather than bytes-per-pixel, so you can think of it as being a 1.25 on your scale.

I'm surprised that PNGs are so high -- 2.4 bytes per pixel is almost as bad as a raw 24bpp image (3.0 should be the absolute worst for any image without transparency). Have you done any work on correlating that value with the image size?

clelland avatar Aug 14 '18 14:08 clelland

Re: have you done any work on correlating that value with the image size

Please see the chart below (this is non compressed PNG images): chart

loonybear avatar Aug 14 '18 15:08 loonybear

OK I went back to look at the data: I saw a quite few PNG images with image size of 1x1 / 2x2 but a relatively large file size. I will remove those and recalculate the average

loonybear avatar Aug 14 '18 15:08 loonybear

It's probably possible to infer this from the graph you posted, but what does it look like if plot compression ratio over number-of-pixels?

clelland avatar Aug 14 '18 20:08 clelland