Confused about colorspace handling

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
joew
Posts: 42
Joined: 2012-08-23T01:19:56-07:00
Authentication code: 67789

Confused about colorspace handling

Post by joew »

Hello wizards,

I have read http://www.imagemagick.org/Usage/color_basics/, http://www.4p8.com/eric.brasseur/gamma.html, and a lot more. But the more I read, the more confused I get.

I have some photographs (JPEG, RGB, exif profile attached). I want to process them (resize, attach borders, overlay some text, and some more operations) and print them on a CMYK printer (color printers are always CMYK, aren't they?)

From http://www.4p8.com/eric.brasseur/gamma.html I learned, I need to

Code: Select all

convert in.jpg -depth -gamma 0.454545 -do -some -processing -gamma 2.2 out.png
or something.

Is it really that easy? What about the profile that is embedded in the original photograph? I guess IM will properly detect them? But don't I need to tell IM about the fact that the final output is going to be an CMYK printer?

Update: I forgot one question: what about images created from other sources (e.g. plasma:some-color) that will be combined with the photographs? In which colorspace should they be created?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Confused about colorspace handling

Post by fmw42 »

I believe, though am not positive, that most IM functions that mix different color effects probably need to be done in RGB. So you may have to convert your CMYK image to RGB, process them, then convert back to CMYK. The best way would be to use profiles, but you can try -colorspace.

Any one, feel free to correct my comment.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Confused about colorspace handling

Post by anthony »

For colorspace handling using profiles see...
http://www.imagemagick.org/Usage/formats/#profiles

However you should convert the colorspace to a linear colorspace before operating on it. Or at least that is the question of some intense discussion in other topics.

Also JPEG by default (if no colorspace profile given) is to use sRGB as the colorspace which his similar to but not quite the same as the gamma corrected method. (Difference is a linear component in the very dark colors).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
joew
Posts: 42
Joined: 2012-08-23T01:19:56-07:00
Authentication code: 67789

Re: Confused about colorspace handling

Post by joew »

Thanks for the answers, but I'm still somewhat confused
fmw42 wrote:I believe, though am not positive, that most IM functions that mix different color effects probably need to be done in RGB. So you may have to convert your CMYK image to RGB
The input jpeg already is in RGB and seems to have a profile attached. So I guess I can skip this step? Or do I still have to do the "-depth 16 -gamma 0.454545" step?

Here is the information from the input file:

Code: Select all

$ identify -verbose DSC_0304.JPG |egrep -i '(profile|colorspace)'
  Colorspace: RGB
    exif:ColorSpace: 1
    jpeg:colorspace: 2
  Profiles:
    Profile-exif: 65532 bytes
$
anthony wrote:For colorspace handling using profiles see...
http://www.imagemagick.org/Usage/formats/#profiles
Yeah, I found that. And I downloaded the profile files for my printer from xerox. But none of the files in the downloaded zip seem to be suitable. Here is the file list of the printer profiles:

Code: Select all

$ unzip -t ~/Downloads/CQ8700-8900_Pantone.zip | grep -v '/ '
Archive:  /home/jw/Downloads/CQ8700-8900_Pantone.zip
    testing: CQ8700-8900_Pantone/Application Support Files/Adobe/Illustrator/Xerox ColorQube 8700_8900.ai   OK
    testing: CQ8700-8900_Pantone/Application Support Files/Adobe/Indesign/Xerox ColorQube 8700_8900.acb   OK
    testing: CQ8700-8900_Pantone/Application Support Files/Adobe/Photoshop/Xerox ColorQube 8700_8900.aco   OK
    testing: CQ8700-8900_Pantone/Application Support Files/Corel/CorelDesigner/Xerox ColorQube 8700_8900.cpl   OK
    testing: CQ8700-8900_Pantone/Application Support Files/Corel/CorelDesigner/Xerox ColorQube 8700_8900.pal   OK
    testing: CQ8700-8900_Pantone/Application Support Files/Corel/CorelDesigner/Xerox ColorQube 8700_8900.pl4   OK
    testing: CQ8700-8900_Pantone/Application Support Files/Corel/CorelDraw/Xerox ColorQube 8700_8900.cpl   OK
    testing: CQ8700-8900_Pantone/Application Support Files/Corel/CorelDraw/Xerox ColorQube 8700_8900.pal   OK
    testing: CQ8700-8900_Pantone/Application Support Files/Quark/Xerox ColorQube 8700_8900 UI Spec.cui   OK
    testing: CQ8700-8900_Pantone/Application Support Files/Quark/Xerox ColorQube 8700_8900.qcl   OK
    testing: CQ8700-8900_Pantone/Application Support Files/Quark/Xerox ColorQube 8700_8900.qxd   OK
    testing: CQ8700-8900_Pantone/Calibrated Look-up Table/Xerox ColorQube 8700_8900.pdf   OK
    testing: CQ8700-8900_Pantone/EPS/1-16.eps   OK
    testing: CQ8700-8900_Pantone/EPS/113-128.eps   OK
    testing: CQ8700-8900_Pantone/EPS/129-144.eps   OK
    testing: CQ8700-8900_Pantone/EPS/145-160.eps   OK
    testing: CQ8700-8900_Pantone/EPS/161-176.eps   OK
    testing: CQ8700-8900_Pantone/EPS/17-32.eps   OK
    testing: CQ8700-8900_Pantone/EPS/177-192.eps   OK
    testing: CQ8700-8900_Pantone/EPS/193-195.eps   OK
    testing: CQ8700-8900_Pantone/EPS/33-48.eps   OK
    testing: CQ8700-8900_Pantone/EPS/49-64.eps   OK
    testing: CQ8700-8900_Pantone/EPS/65-80.eps   OK
    testing: CQ8700-8900_Pantone/EPS/81-96.eps   OK
    testing: CQ8700-8900_Pantone/EPS/97-112.eps   OK
    testing: CQ8700-8900_Pantone/Look Up Table Text/Xerox ColorQube 8700_8900.pdf   OK
    testing: CQ8700-8900_Pantone/Look Up Table Text/Xerox ColorQube 8700_8900.txt   OK
    testing: CQ8700-8900_Pantone/PANTONE Color Support User Guide.pdf   OK
    testing: CQ8700-8900_Pantone/Printer Settings/Xerox ColorQube 8700_8900 Print Settings.txt   OK
    testing: CQ8700-8900_Pantone/TIFF/1-16.tif   OK
    testing: CQ8700-8900_Pantone/TIFF/113-128.tif   OK
    testing: CQ8700-8900_Pantone/TIFF/129-144.tif   OK
    testing: CQ8700-8900_Pantone/TIFF/145-160.tif   OK
    testing: CQ8700-8900_Pantone/TIFF/161-176.tif   OK
    testing: CQ8700-8900_Pantone/TIFF/17-32.tif   OK
    testing: CQ8700-8900_Pantone/TIFF/177-192.tif   OK
    testing: CQ8700-8900_Pantone/TIFF/193-195.tif   OK
    testing: CQ8700-8900_Pantone/TIFF/33-48.tif   OK
    testing: CQ8700-8900_Pantone/TIFF/49-64.tif   OK
    testing: CQ8700-8900_Pantone/TIFF/65-80.tif   OK
    testing: CQ8700-8900_Pantone/TIFF/81-96.tif   OK
    testing: CQ8700-8900_Pantone/TIFF/97-112.tif   OK
No errors detected in compressed data of /home/jw/Downloads/CQ8700-8900_Pantone.zip
$
However you should convert the colorspace to a linear colorspace before operating on it.
But isn't RGB already a linear colorspace? Or do I have to do an explicit step of "-colorspace RGB" and strip the profile? Can I skip the "-depth 16 -gamma 0.454545" step when there's a profile attached to the image?
Also JPEG by default (if no colorspace profile given) is to use sRGB as the colorspace which his similar to but not quite the same as the gamma corrected method. (Difference is a linear component in the very dark colors).
[/quote]
In this case, as shown above, the color space seems to be RGB, and a profile is attached, so I can skip the "-depth 16 -gamma 0.454545" step?

And what about the output? Do I have to do an explicit "-gamma 2.2 -colorspace CMYK" after all the processing have been done?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Confused about colorspace handling

Post by fmw42 »

Colorspace RGB and sRGB got swapped over a number of releases, starting at about 6.7.5.5 and through about 6.7.6.7. So it really depends upon what IM version you are using. For older versions of IM colorspace=RGB was really sRGB and vice-versa. Afterwards colorspace RGB was linear RGB and sRGB was non-linear sRGB


see viewtopic.php?f=4&t=21269
Post Reply