I fixed the two problems here:
-
The image optimization pipeline converted PNGs to JPEGs and then tried to optimize resulted JPEGs using the operations for PNG images.
-
ImageMagick errors were returned to the user, but were not helpful at all (e.g.
convert: improper image header...
)