Losslessly remove chrominance channels iff JPEG is grayscale
Posted: 2017-12-29T01:15:51-07:00
Is there a way of losslessly reducing a JPEG image's bit-depth to 8 if it's already in grayscale? losslessly chooses the appropriate bit-depth for a grayscale PNG but results in recompression for JPEG. I'm currently using and checking to see if is "0 (0)" before replacing the image, though I'd prefer an IM-only solution if possible.
Code: Select all
magick convert image image
Code: Select all
jpegtran -grayscale -outfile tmpImage
Code: Select all
magick compare -metric rmse image tmpImage NUL