Via this blog post I came across this PHP image optimization library, which somewhat reminds me of this blog post from a couple of years ago. As good as ImageMagick is, it takes time and effort to find all the right options. With Spatie Image Optimizer you have an almost out of the box solution for optimizing images in a variety of formats.
This package can optimize PNGs, JPGs, SVGs and GIFs by running them through a chain of various image optimization tools.