Which color profile for greyscale JPEG?

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
the-ninth
Posts: 27
Joined: 2010-12-25T09:22:24-07:00
Authentication code: 8675308

Which color profile for greyscale JPEG?

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Which color profile for greyscale JPEG?

Post 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
snibgo's IM pages: im.snibgo.com
the-ninth
Posts: 27
Joined: 2010-12-25T09:22:24-07:00
Authentication code: 8675308

Re: Which color profile for greyscale JPEG?

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Which color profile for greyscale JPEG?

Post by snibgo »

One of the escapes should give that, perhaps %[type]. See http://www.imagemagick.org/script/escape.php
snibgo's IM pages: im.snibgo.com
the-ninth
Posts: 27
Joined: 2010-12-25T09:22:24-07:00
Authentication code: 8675308

Re: Which color profile for greyscale JPEG?

Post by the-ninth »

Thanks!
Post Reply