Page 1 of 1

Which color profile for greyscale JPEG?

Posted: 2016-04-01T05:17:09-07:00
by the-ninth
Hi,

I have a question in reference to this old thread:

https://www.imagemagick.org/discourse-s ... hp?t=16699

Basically I have the same issue as discussed in the first three posts in the thread. I downsize an image using ImageMagick and retain the embedded color profile. For black&white images, ImageMagick changes the JPEG type to greyscale, when then opening the downsized file, Photoshop complains about an invalid profile, because it does not like the RGB color profile embedded in an greyscale JPEG. In the thread, the problem is solved by forcing ImageMagick to stick with a color JPEG (-type TrueColor).

However, I do not want to enforce the color JPEG, because going for greyscale actually saves a few kilobytes. So what would be the correct solution if I want to do that? Would I need to embed a different color profile? Where would I get that profile from?

Thanks!

Cheers, Robert

Re: Which color profile for greyscale JPEG?

Posted: 2016-04-01T06:08:10-07:00
by snibgo
I would "-strip" the profile. Then any software will assume the the tonal values are sRGB. For accuracy, you should convert it to an sRGB profile before stripping, and you should do this before converting to grayscale, for example:

Code: Select all

convert in.jpg -profile sRGB.icc -strip -colorspace Gray out.jpg

Re: Which color profile for greyscale JPEG?

Posted: 2016-04-01T09:20:01-07:00
by the-ninth
Hi Snibgo,

Thanks for your response! Do you have an idea how I could detect if an image is grey-scale in the first place? My code needs to be able to handle both color and grey-scale pictures.

Regards, Robert

Re: Which color profile for greyscale JPEG?

Posted: 2016-04-01T09:38:35-07:00
by snibgo
One of the escapes should give that, perhaps %[type]. See http://www.imagemagick.org/script/escape.php

Re: Which color profile for greyscale JPEG?

Posted: 2016-04-01T10:43:25-07:00
by the-ninth
Thanks!