I wonder how much bandwidth I've wasted for people over the years because I've saved poorly optimised versions from Photoshop. Are there automated tools that can be included in a CI pipeline to help with this?
I wonder how much bandwidth I've wasted for people over the years because I've saved poorly optimised versions from Photoshop. Are there automated tools that can be included in a CI pipeline to help with this?
One particular trick is getting images with visually low number of distinct colors, like logos and screenshots, through pngquant. You don't have to worry whether the actual number of colors is less than 256, how to posterize or filter the image to decrease that number, or how to suppress artificial colors from font anti-aliasing — the tool measures the visual likeness, and provides the means to set the acceptable limit so it would leave unsuitable images intact. Obviously, when you're dealing with some long-term archival storage, or assets for further editing like stock clipart, such presentation-oriented lossy optimization should not be used.
Other automatic tools are referenced in the article, though you should treat them as a nice sanity check that prevents images holding raw uncompressed data or simple two color graphs saved as 4 byte RGBA from appearing in your project, and not a magical solution that would send it to the sky performance-wise.
Bandwidth (and loading time) is usually wasted on complex high resolution images like photos or combined graphics with photographic details. These can't really be optimized well enough in PNG with naive lossless or lossy methods, and have to be converted to JPEG to reach sane size or regenerated as independent layers that use different compression.
I recall PNG8 not being well supported in some applications. I've run into this with game engines, which I found strange since asset size is an important thing to keep in mind.
There were some IE-specific hacks you could use with their proprietary CSS extensions but they were really annoying. I think IE7 finally fixed the transparency bugs but since there was still a huge IE6 cohort it was still a crapshoot relying on transparent PNGs.
[1] https://packages.debian.org/unstable/optipng
[2] https://packages.debian.org/unstable/pngcrush
[3] http://www.olegkikin.com/png_optimizers/Which contains all of those and just tries them all. Been meaning to pop it all out and make a bash script of them to automate some of my stuff on a cron job instead of using a GUI.