Page 1 of 1

Invalid color profile for colorless images in RGB colorspace

Posted: 2013-10-05T02:14:10-07:00
by leonidas
Hello,

i am experiencing a rather confusing issue. The procedure is as follows.

1. Extract color profile from image
2. Do some image processing (resizing, resampling, etc.)
3. Embed the original profile and create a TIF

This works really well, with one exception. If the original image that is provided contains no color information (a grayscale image) but is set to RGB, then the resulting TIF after step 3 will contain an invalid color profile. Therefore a variety of professional printing machines will not accept it and photoshop, upon opening such an image, will state that the color profile is invalid and cannot be used.

I was digging for solutions and found a thread here which basically resulted in the user modifying his installed ImageMagick version instead of actually working around the problem. I also found a thread on Stackoverflow where a user wrote that it works for him to pick a random pixel from the image, add a few color values to it and then write it back into the original image before further processing. But unfortunately this is not an option for me and i fail to understand why it would have to be done. There must be a correct way to do this.

Here is what is running on my server:
Version: ImageMagick 6.8.6-8 2013-08-19 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC OpenMP Modules
Delegates: bzlib djvu fontconfig freetype gslib jng jp2 jpeg lcms openexr pango png ps rsvg tiff wmf x xml zlib
Can you guys help me out and tell me how to solve this problem?

Thank You!

Re: Invalid color profile for colorless images in RGB colors

Posted: 2013-10-05T05:03:24-07:00
by holden
Is it possible just to apply a specific printer profile to the image, or simply sRGB, AdobeRGB, whatever the printers want? So for example convert image.tiff ( processing stuff here ) -profile sRGB.icc outimage.tiff

* I should actually say "it is possible" in that the above code is what I do :)

Re: Invalid color profile for colorless images in RGB colors

Posted: 2013-10-05T05:28:01-07:00
by leonidas
Thank You for your input.

The problem is that this runs in a huge print company. I cannot afford to modify the color information in any way, as it must be printed according to the client's needs.

Now with a purely colorless image that would not be a problem or make a difference, right? But how do i actually know that the image contains no colours when its colorspace is actually RGB?

Re: Invalid color profile for colorless images in RGB colors

Posted: 2013-10-05T05:43:45-07:00
by holden
I'm not too sure why the original profile is being extracted in the first place- when the gurus around here wake up they will more than likely ask for your exact IM commands btw.

Have you tried running the original customer image through before doing any processing?

Re: Invalid color profile for colorless images in RGB colors

Posted: 2013-10-05T07:42:19-07:00
by snibgo
I don't understand the problem.

I assume the actions in OP's step 2 are irrelevant. They might do nothing at all. So:

1. Extract color profile from image
3. Embed the original profile and create a TIF

Assuming the original image is valid, how does it end up invalid?

Yes, please show us the exact commands. A sample image that shows the problem might also help.

Re: Invalid color profile for colorless images in RGB colors

Posted: 2013-10-05T08:14:07-07:00
by leonidas
Yes, when i open the original image, things are going just fine. Photoshop is opening it without a hassle.
But after processing, there is the error.

This is the original image:
http://leers.com/downloads/original_picture.jpg

This is the processed one with the embedded original profile.
http://leers.com/downloads/after.jpg

NOTE: Sorry, due to server restrictions i had to rename after.tif to after.jpg so you can fetch it. Just change the extension to TIF after downloading it.

Here are the commands i run:

Code: Select all

convert original_picture.jpg icc:profile.icc
convert original_picture.jpg -crop 1000x1000+0+0 +repage -resample 200x200 -resize 800x800 -compress lzw -profile profile.icc after.tif
Please note that the crop and resize parameter values are fictional in this example.

Sidenote: I am also having issues with the resulting image regarding its dimensions. Because of the resampling i get unrounded centimeter values (ie. 59,94 x 39,97) which messes up automated merged prints on a lambda machine. If anyone knows how to fix this, please let me know as well. Thanks!

Re: Invalid color profile for colorless images in RGB colors

Posted: 2013-10-05T08:34:17-07:00
by snibgo
I assume for "original_image" I can read "original_picture".

original_picture.jpg contains a profile (which is an sRGB profile, as it happens). You make a copy of the profile. In your second convert, the output already contains the profile, yet you apply it again. Why? It should be harmless, but pointless.

I don't have Photoshop, so can't test the output with PS. Does it say which profile it doesn't like? The image also contains 8bim, exif, iptc and xmp profiles. IM shouldn't touch these, and "identify -verbose" suggests it doesn't.

Re: Invalid color profile for colorless images in RGB colors

Posted: 2013-10-05T09:03:54-07:00
by snibgo
Your after.tif is darker than original_picture.jpg, and the difference corresponds to a RGB/sRGB problem (ie "-gamma 2.2" cures it). This suggests you are actually using an older version of IM than the claimed v6.8.6-8.

Sorry I don't have Photoshop. If I did, I would:
1. Confirm that it can read original_picture.jpg but not after.tif
2. Change the output to after.jpg and remove "-compress LZW". Check if PS can read after.jpg.
3. Remove crop, repage, resample and resize. Check if PS can read after.jpg.
4. Remove profile. Check if PS can read after.jpg.

This should pin down which IM operation is causing the readability problem. If you do this, please put the results here.

Re: Invalid color profile for colorless images in RGB colors

Posted: 2013-10-05T09:06:05-07:00
by leonidas
I ended up re-embedding it because for whatever reasons in my tests i found that in the final TIF i am left without the original profile unless i explicitly do so.

Photoshop states:

"The embedded ICC-Profile can not be used, because the ICC-Profile is invalid. The profile is being ignored."

And the printer simply declines printing the image.

Re: Invalid color profile for colorless images in RGB colors

Posted: 2013-10-05T09:12:30-07:00
by snibgo
leonidas wrote:I ended up re-embedding it because for whatever reasons in my tests i found that in the final TIF i am left without the original profile unless i explicitly do so.
Please try the following:

Code: Select all

convert original_picture.jpg a.tif
identify a.tif
Does a.tif contain the profile? It does for me, on v6.8.6-5 (the closest I have to your version).
leonidas wrote:Sidenote: I am also having issues with the resulting image regarding its dimensions. Because of the resampling i get unrounded centimeter values (ie. 59,94 x 39,97) which messes up automated merged prints on a lambda machine. If anyone knows how to fix this, please let me know as well. Thanks!
I wouldn't do both resample and resize. "-resample" is effectively a "-resize" and "-density". "-resize" mushes pixels, and doing it more than once isn't good for quality.

Re: Invalid color profile for colorless images in RGB colors

Posted: 2013-10-05T10:09:33-07:00
by snibgo
leonidas wrote:Photoshop states: "The embedded ICC-Profile can not be used, because the ICC-Profile is invalid. The profile is being ignored."
See also thread viewtopic.php?f=3&t=16699&p=99519 where that error was solved by inserting "-type TrueColor" before the output filename.