Question

I used ngx_pagespeed to optimize my Nginx servers. One of the servers is an image reverse proxy that supposed to fetch images from a remote server, optimize it, and send back to the client. However, most of the remote images are already optimized under PNG24 so pagespeed will just drop it with image_rewrites_dropped_nosaving_noresize count increased by one. If I manually optimize such image with PNG8, it will save a lot without really hurting my images, in my case.

Is there a way to force ngx_pagespeed to optimize with PNG8 or any other parameters I can try? Note lossless compression is not a requirement for my case. I also tried converting to webP but didn't gain too much.

Thank you

Était-ce utile?

La solution

Thanks for using ngx_pagespeed. Next time you may write to "ngx-pagespeed-discuss@googlegroups.com" for quicker response.

I understand that PNG8 is more effective in reducing bytes, as compared to PNG24. Images with 256 colors or less will fit perfectly in PNG8. However, images with more colors would have degraded quality if they were converted to PNG8.

ngx_pagespeed does not convert PNG24 to PNG8 to avoid the potential loss of quality. And I'm sorry that currently there is no way to force such conversion. However, ngx_pagespeed keeps improving the image compression performance and may do the automatic conversion for 256 colors and below.

If your images don't have alpha channel (transparent color) and you are okay with lossy compression, you can turn on the "convert_png_to_jpeg" filter. This filter will convert PNG images to JPEG if the latter has few bytes.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top