Embedded ICC profile is invalid in converted JPEG

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
CatBurgers
Posts: 9
Joined: 2014-10-03T11:56:34-07:00
Authentication code: 6789

Re: Embedded ICC profile is invalid in converted JPEG

Post by CatBurgers »

glennrp wrote:The American flag image is a grayscale JPEG. It contains at least two sRGB profiles. Grayscale images are only allowed to have grayscale ICC profiles.
There must be something I'm not understanding. Like you said, the original image has two sRGB profile that I can tell using identify:

Code: Select all

icc:description: sRGB IEC61966-2.1
...
photoshop:ICCProfile: sRGB IEC61966-2.1
However, it's not until it's been processed by imagemagick that photoshop is reporting an error when trying to open the image. If I diff the results of identify for both the original file and the one outputted by imagemagick I get this (notable: class is changed from Directclass to PseudoClass, colorspace is changed from 2 to 1, rendering intent is changed from Perceptual to Undefined, Chromacity is removed and Colormap entries and Colormap are added).

I'm guessing that I would need to mitigate this issue by converting from sRGB to a grayscale icc profile like you said but how would I go about to do that? I can't find any grayscale ICC profile out there.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Embedded ICC profile is invalid in converted JPEG

Post by snibgo »

americanflag01BW.jpg has three colour channels: YCbCr.

Code: Select all

convert -verbose americanflag01BW.jpg x.jpg
x.jpg has ony one colour channel.

Code: Select all

convert -verbose americanflag01BW.jpg -type truecolor x2.jpg
x2.jpg has three colour channels: YCbCr.

As jpg files cannot contain transparency, and you always want three colour channels, "-type truecolor" seems to be the solution.
snibgo's IM pages: im.snibgo.com
CatBurgers
Posts: 9
Joined: 2014-10-03T11:56:34-07:00
Authentication code: 6789

Re: Embedded ICC profile is invalid in converted JPEG

Post by CatBurgers »

How would I identify the color channels? Using identify, both pre and post convert show

Code: Select all

Depth: 8-bit
Channel depth:
gray: 8-bit
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Embedded ICC profile is invalid in converted JPEG

Post by snibgo »

"identify" tells you what the data looks like, after IM has read it in. For your purpose, you care about the data in the file. exiftool tells us this.
snibgo's IM pages: im.snibgo.com
CatBurgers
Posts: 9
Joined: 2014-10-03T11:56:34-07:00
Authentication code: 6789

Re: Embedded ICC profile is invalid in converted JPEG

Post by CatBurgers »

Okay, so what I'm currently using is identify to detect the Grayscale type and exiftool to detect Color Components higher than one and if both these tests are positive, I use -type TrueColor when converting. Does that make sense?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Embedded ICC profile is invalid in converted JPEG

Post by snibgo »

I don't use Photoshop so can't say what you need to do.

But if you want to guarantee the output has three colour channels, "-type truecolor" does the job.

I have never encountered grayscale ICC profiles.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Embedded ICC profile is invalid in converted JPEG

Post by fmw42 »

snibgo wrote:I have never encountered grayscale ICC profiles.
I have 3 grayscale icc and icm profiles: GrayTone.icc, jasper_sGray.icm, JMARS_sGray.icc.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Embedded ICC profile is invalid in converted JPEG

Post by snibgo »

Ah, interesting. Can you put them somewhere accessible?
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Embedded ICC profile is invalid in converted JPEG

Post by fmw42 »

P.S. You can emulate sgray (as suggested by user Drarakel as I recall)

Code: Select all

convert image -colorspace sRGB -intensity rec709luminance \
-colorspace gray -set colorspace RGB -colorspace sRGB result
see examples at http://www.fmwconcepts.com/imagemagick/ ... /index.php
Post Reply