To be honest ... this is IMHO by far one of the most complicated thing in the whole webdev area.
I don't get it why ppl complain about how difficult CSS is ... but to foresee how an image behaves and find a good balance between size and file size is a hart thing to juggle with.
This article clarifies a lot of things for me so thx for that.
Also, teaching non-engineers about the different file types to use (like not using PNGs for raster content) is another realm of complexity.
Optimizing images programmatically is easy. Converting them between PNG and JPG programmatically, along with determining when such a conversion should happen, is very difficult.
This article clarifies a lot of things for me so thx for that.