Preserving Color Profile for Renditions

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
ChristianJP
Posts: 3
Joined: 2016-11-27T11:09:51-07:00
Authentication code: 1151

Preserving Color Profile for Renditions

Post by ChristianJP »

Hello,

I am working on an IM script. The intent is to auto populate renditions from master files (incl. .TIF, .PSD, .JPG). One rendition is to generate CMYK. I've successfully created the various renditions using this script:

@echo off

set ORIGINAL_FOLDER=.\original-assets
set RENDITION_FOLDER=.\renditions

for /f %%A in ('dir /B %ORIGINAL_FOLDER%') DO (
echo Generating Renditions for %%A...
::* Generate 300 dpi CMYK Rendition
convert %ORIGINAL_FOLDER%/%%A -define jpeg -density 300 -colorspace CMYK -gravity center %RENDITION_FOLDER%/300CMYK/%%A_300CMYK.jpg

::* Generate 300 dpi RGB Rendition
convert %ORIGINAL_FOLDER%/%%A -define jpeg -density 300 -colorspace RGB -gravity center %RENDITION_FOLDER%/300RGB/%%A_300RGB.jpg

::* Generate 150 dpi RGB Rendition
convert %ORIGINAL_FOLDER%/%%A -define jpeg -density 150 -colorspace RGB -gravity center %RENDITION_FOLDER%/150/%%A_150.jpg

::* Generate 72 dpi Rendition
convert %ORIGINAL_FOLDER%/%%A -define jpeg -density 72 -colorspace RGB -gravity center %RENDITION_FOLDER%/72/%%A_72.jpg
)

HOWEVER, the resulting color is off.
In Photoshop, for example, when I save the .PSD as a .JPG, I make the following choices:
Include Layers
Embed Color Profile: US Sheetfed Coated v2
No Compression
Interleaved Pixel Order
Layer Compression: RLE

How do I get the correct color profile in my resulting renditions?

I've tried adding: -profile USSheetfedCoasted.icc , but did not specify a profile path. this did not work.

I also tried adding -profile sRGB just after the -define, then -colorspace sRGB - strip at the end. this did not work.

This is a command line script which will be run by an enterprise program when finalized.

Thank you!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Preserving Color Profile for Renditions

Post by fmw42 »

You have to supply the full path to your selected profile, which must be on your system. The -profile ... should be added just before writing the output image, presumably already CMYK. Or better, take your RGB image make sure (or add) -profile path2/sRGB.icc -profile path2/USWebCoatedSWOP.icc to convert your RGB image to CMYK (without using -colorspace CMYK). The latter is the proper way.

Why do you need -define jpeg? Your output suffix of .jpg is enough. In fact, I do not know that there is a -define jpeg command!

You should probably add -units pixelsperinch to be sure the density has a proper units associated with it and not undefined.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Preserving Color Profile for Renditions

Post by snibgo »

Please say what version IM you are using.
ChristianJP wrote:-colorspace RGB
I suspect you wanted "-colorspace sRGB", so this is one source of your colour problems.

Conversion between sRGB and CMYK should generally be done with "-profile", not "-colorspace".

You need to provide the path to your profile files, if they are not in the current directory.
snibgo's IM pages: im.snibgo.com
Post Reply