Losslessly remove chrominance channels iff JPEG is grayscale

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
hoanghuynh
Posts: 2
Joined: 2018-01-09T20:05:27-07:00
Authentication code: 1152

Losslessly remove chrominance channels iff JPEG is grayscale

Post by hoanghuynh »

Is there a way of losslessly reducing a JPEG image's bit-depth to 8 if it's already in grayscale?
CODE: SELECT ALL

magick convert image image
losslessly chooses the appropriate bit-depth for a grayscale PNG but results in recompression for JPEG. I'm currently using
CODE: SELECT ALL

jpegtran -grayscale -outfile tmpImage
and checking to see if
CODE: SELECT ALL

magick compare -metric rmse image tmpImage NUL
Post Reply