Definitely want to look into JIMP library mentioned... curiousities on features likely to be missing, but would be nice include...
For jpeg in particular:
* un-rotate image (in other words, clear the rotation and actually match the image without rotation metadata to the image detail), this happens a lot with images taken on phones.
* preserve/copy metadata (such as geolocation, etc) into newly saved images.
For png:
* palette reduction (and quantization) - png gets a lot smaller when you get your colors to a limited palette, which includes alpha channels. quantization will allow this to be reduced on images with more colors, the effects can be good to very bad, but often a huge boost combined for both with png output.
These are all features that are often missing from these types of libraries, and run into dedicated libraries. I've been hoping for a while that the builds for the libraries used with squoosh could be made into individual npm packages using web-assembly for web and node. Which should allow for interop as long as those wasm bundles are gpl, the use of them afaik doesn't require it.