`resize_image` default compression parameters for PNG often make files larger
Bug Report
Environment
Zola version: 0.18.0
Expected Behavior
I'm playing with using a shortcode + resize_image to automatically do responsive images on my website. I'm specifically using:
resize_image(path=abspath, width=s, op="fit_width")Part of my goal is to have my users pull fewer bytes, and for my server to serve less traffic, when it isn't required. So, I expected one of the following to happen:
- Resizing an image to make it smaller would reduce file size.
- There would be parameters available for me to override the defaults if the defaults didn't reduce file size.
Current Behavior
Resizing the attached 1440px wide PNG to 1000 and 500 px wide greatly increases the file size.
- Original 1440px image: 37,970 bytes
- Shrunk to 1000px with Zola: 202,972 bytes (535%)
- Shrunk to 500px with Zola: 87,897 bytes (231%)
Simply opening and re-exporting the 1000px image with Gimp 2.10.36 cuts the size in half, though the result is still bigger than the original, likely because Zola used bicubic/bilinear interpolation and greatly increased the number of colors. (I have a bunch of diagrams on my site that compress well.) Re-quantizing the color palette manually caused the 1000px result to be smaller than the original (29,492 bytes).
One possibility for fixing this would be to expose control over the scaling method and output format, though based on Gimp's output without manual optimizations, I think Zola's PNG compressor may not be set up correctly.
(This may or may not affect other image formats. I haven't tested yet.)
Step to reproduce
Feed the attached PNG through resize_image on 0.18 (possibly other versions, haven't checked).
Source: getzola/zola