Page 1 of 1

how to determine and match a color profile

Posted: 2007-04-03T09:54:00-07:00
by andrewadperfect
GOAL: Currently I have PDF and/or EPS files coming to me which I want to then convert
to JPG format. The PDF/EPS files are in CMYK, and the JPG after being output in RGB,
should look as close as possible (not exact, just close). PDF files are always converted
to EPS before further processing so that's my starting point.

IDEA: I would like to be able to analyse the EPS file, determine what color profile is being
used, and convert it to a JPG. If I could read the color profile name, I could check it against
a list of color profile files I have, and if not present, fall back to the generic one. At this
point, the identify -verbose command says nothing about profiles for my EPS.

OTHER INFO:
I am using everything on the command line, no GUI or PerlMagick, etc.

QUESTIONS:

1) Can ImageMagick determine the color profile name using the identify command?
I have found a way with some JPG files to pull out an .icc file, but it didn't contain the
name, just the specs. I need some way to match it to a filename.

1a) If identify can't get the name directly, is there a roundabout way this might be done?

2) If ImageMagick cannot determine the actual name, is there anything that can?
I guess what I would like is to get a value such as 'USWebCoatedSWOP.icc'
or 'Generic CMYK Profile.icc'.

3) If an image or EPS contains a profile, and the convert command is run on it, will it
by default use that profile? In addition, if a profile is specified on the command line,
will it overwrite the embedded profile, or will the embedded one keep priority?


I have searched the board but haven't found answers that are exactly what I need.

Re: how to determine and match a color profile

Posted: 2007-04-03T09:56:41-07:00
by andrewadperfect
For further information, here is the output for my identify commad on a file I'm working with:

$ identify -verbose 9876543210.eps
Image: 9876543210.eps
Format: PS (PostScript)
Class: DirectClass
Geometry: 612x792+0+0
Type: ColorSeparation
Endianess: Undefined
Colorspace: CMYK
Channel depth:
Cyan: 8-bit
Magenta: 8-bit
Yellow: 8-bit
Black: 8-bit
Channel statistics:
Cyan:
Min: 0 (0)
Max: 255 (1)
Mean: 36.2728 (0.142246)
Standard deviation: 73.9381 (0.289953)
Magenta:
Min: 0 (0)
Max: 254 (0.996078)
Mean: 37.516 (0.147121)
Standard deviation: 72.6916 (0.285065)
Yellow:
Min: 0 (0)
Max: 255 (1)
Mean: 25.0304 (0.0981583)
Standard deviation: 52.7081 (0.206699)
Black:
Min: 0 (0)
Max: 255 (1)
Mean: 21.3221 (0.083616)
Standard deviation: 48.7586 (0.19121)
Total ink density: 341%
Colors: 70589
Rendering intent: Undefined
Resolution: 72x72
Units: Undefined
Filesize: 1.85311mb
Interlace: None
Background color: white
Border color: cmyk(223,223,223,0)
Matte color: grey74
Transparent color: black
Page geometry: 612x792+0+0
Dispose: Undefined
Iterations: 0
Compression: Undefined
Orientation: Undefined
Ps:HiResBoundingBox: 612x792+0+0
Ps:Level: Adobe-3.0 EPSF-3.0

Ps:SpotColor-0: atend
Ps:SpotColor-1: font APHelv-Bold
Ps:SpotColor-2: font APHelv
Signature: 98f062a1eac9f23318acd4399310f99da5305dab6b85a1aacd7a
Tainted: False
Version: ImageMagick 6.3.3 03/30/07 Q16 http://www.imagemagick.org


-------------

No mention of profile...

Re: how to determine and match a color profile

Posted: 2007-07-09T09:52:03-07:00
by martinw17
I need to do a similar thing, so please let me know if you manage to find answers to 1 & 2!

Regarding 3, I'm pretty sure convert works like this:
- If the image contains an embedded color profile then the first (and only) -profile option is used to specify the destination color space.
For example:
convert cmyk-with-embedded-profile.esp -profile /path/to/sRGB.icm my-rgb.jpg
converts the source image into an sRGB jpg, using the embedded profile.

- If the image does not contain an embedded profile then the first -profile option is used to specify the source color profile. The second -profile option is used to specify the destination color profile.
For example:
convert cmyk-with-embedded-profile.esp -profile /path/to/USWebCoatedSWOP.icc -profile /path/to/sRGB.icm my-rgb.jpg

This means that the first command given above will give strange results if the source image does not contain an embedded profile as convert will assume that -profile /path/to/sRGB.icm is specifying the source color profile.

I'm pretty sure that if you specify both -profile options to convert then the embedded profile will be ignored.

Re: how to determine and match a color profile

Posted: 2007-07-09T10:02:39-07:00
by andrewadperfect
No, I didn't find a way to do this. However, in the end, just specifying a color
profile was good enough... I didn't have to know the exact color profile name.

It would be nice to know though. If anyone reading this knows how, I think
we'd all appreciate knowing. Perhaps there is some method of extracting a
color profile and analysing it?

Re: how to determine and match a color profile

Posted: 2010-05-09T22:13:44-07:00
by adrianlambert
I'm looking for a solution for this too. I've piped the identify -verbose result through grep to search for the colour space then removed the line with the "colorspace:" tag to leave just the nice name.

Code: Select all

Index:~ adrian$ identify -verbose EvaPassport.jpg | grep -E "Grey|RGB|sRGB|CMYK" | grep -v Colorspace | less

      Adobe RGB (1998)
~
~
~
I am very inexperienced in unix scripting so it may not be the best way, but it works for my purposes.

Re: how to determine and match a color profile

Posted: 2010-05-10T01:31:48-07:00
by martinw17
If you just need the name of the colorspace, you could use:
identify -format "%r" myimage.jpg

Re: how to determine and match a color profile

Posted: 2010-05-10T02:39:06-07:00
by adrianlambert
martinw17 wrote:If you just need the name of the colorspace, you could use:
identify -format "%r" myimage.jpg
I ran...
identify - format "%r" myimage.jpg | less
...but I just get "DirectClassRGB" where I would expect to see "Adobe RGB (1998)"

is there more to this than I understand?

Re: how to determine and match a color profile

Posted: 2010-05-10T04:54:24-07:00
by snibgo
I'm pretty sure that if you specify both -profile options to convert then the embedded profile will be ignored.
I don't think that is correct. The documentation says (somewhere, I don't have tme to find it) it will convert from the embedded profile to the first one you specify, and from that to the second one.

This means you can always "safely" use the following command on any CYYK file:

convert input.jpg -profile GenericCMYK.icc -profile -sRGB.icc output.jpg

If the input happens to already have GenericCMYK.icc embedded, the first "-profile" will have no effect. If it has a different profile embedded, the data will be converted to GenericCMYK.icc. In both cases, it will then be converted to sRGB.

Re: how to determine and match a color profile

Posted: 2010-05-10T08:19:11-07:00
by Drarakel
snibgo wrote:If the input happens to already have GenericCMYK.icc embedded, the first "-profile" will have no effect
The documentation says something different:
http://www.imagemagick.org/Usage/format ... e_changing
If the original image already contains a profile, for example a CMYK profile, then given two profile conversions is a bad idea.
I think, you should always strip the color profile of the input image if you want to add the source and destination profile manually.

With 'normal' images (JPG, TIF etc.), it's relatively easy to do the proper color conversion. But with PDF/EPS/etc. (Ghostscript), sadly - it's a whole different story. These are complex formats after all.

Re: how to determine and match a color profile

Posted: 2010-05-10T14:49:24-07:00
by snibgo
Two profile conversions is always a bad idea. Each one may lose information, and the first is redundant.

If the input already has a profile, you could strip it then re-add it manually before converting to another profile. The stripping and re-adding is pointless but harmless. You could simply do the "convert" with a single "-profile".

If the input has no profile, but you think it is ABC.icc (such as one of the CMYK profiles), and you want to change it to XYZ.icc (such as one of the sRGB profiles), you need two "-profile" statements. The first will change metadata, and the second actually convert pixel values.

Re: how to determine and match a color profile

Posted: 2010-05-10T15:38:40-07:00
by snibgo
Incidentally, I'm not sure what the original poster is aiming at, but if an image contains an ICC profile, it can be extracted:

convert in.png out.icc

This might answer questions 1a and 2.

Question 3:
3) If an image or EPS contains a profile, and the convert command is run on it, will it
by default use that profile?
By default, "convert" does nothing with an embedded ICC profile. It just passes it through to the output file.
In addition, if a profile is specified on the command line,
will it overwrite the embedded profile, or will the embedded one keep priority?
"Convert" will change the pixel values as required and embed the new profile.

I should say that an EPS might contain multiple images, and I think these could have different profiles. If so, all bets are off.