PSD Conversion

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?".
briandenks
Posts: 29
Joined: 2013-06-19T01:35:25-07:00
Authentication code: 6789

Re: PSD Conversion

Post by briandenks »

i dont do anything with RGB PSD thats my issue, i can only get one or the other to work correctly using -profile cmyk.icc or alternatively -profile sRGB.icc
Im trying to get IM to take either cmyk.psd or rgb.psd (flattened) and process them correctly ( im not fussed on conversion if anything id like them to be color matched and correct as you say cmyk png is a big no no so sRGB.png sRGB.jpg is FINE ) so how do i get IM to script correctly for either a cmyk.psd or rgb.psd to convert without screwing the colors, do i add another profile command ?
Currently my commands :
for DPI : -resample -strip -profile /usr/share/USWebCoatedSWOP.icc
For PPI -resize -strip -profile /usr/share/USWebCoatedSWOP.icc

Are ok with cmyk jpg + tif but are unusable with cmyk png

Want a command that will allow an non profiled CMYK.psd to be converted / resampled / resized/ into png tif jpg without color issues at the same time will take RGB.psd and do the same ...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PSD Conversion

Post by fmw42 »

Do you need the output to have a cmyk profile or do you care if it is srgb profile. That would take care of the PNG issue.
briandenks
Posts: 29
Joined: 2013-06-19T01:35:25-07:00
Authentication code: 6789

Re: PSD Conversion

Post by briandenks »

If its color correct im not fussed i thought it might be possible to hold whatever is given to IM but it appears this isnt the case...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PSD Conversion

Post by fmw42 »

I am not sure about your version 6.6.9 as it was right in the middle of the IM colorspace changes. But this works for me in IM 6.8.6.5 Q16 Mac OSX. I would really suggest you upgrade especially if this does not work on your version.

I opened the file zelda3.jpg in PS and saved it two ways. One was a sRGB output with no profile and the other was a CMYK output with no profile. Then I processed each with the following and the colors look very close to the original.


infile="zelda3srgb.psd"
colorspace=`convert $infile -format "%[colorspace]" info:`
if [ "$colorspace" = "sRGB" ]; then
convert $infile -resize 200% -profile /Users/fred/images/profiles/sRGB.icc test1.png
elif [ "$colorspace" = "CMYK" ]; then
convert $infile -profile /Users/fred/images/profiles/USWebCoatedSWOP.icc -profile /Users/fred/images/profiles/sRGB.icc -resize 200% test2.png
fi


infile="zelda3cmyk.psd"
colorspace=`convert $infile -format "%[colorspace]" info:`
if [ "$colorspace" = "sRGB" ]; then
convert $infile -resize 200% -profile /Users/fred/images/profiles/sRGB.icc test1.png
elif [ "$colorspace" = "CMYK" ]; then
convert $infile -profile /Users/fred/images/profiles/USWebCoatedSWOP.icc -profile /Users/fred/images/profiles/sRGB.icc -resize 200% test2.png
fi
Last edited by fmw42 on 2013-07-15T20:41:58-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PSD Conversion

Post by fmw42 »

Original

Image

sRGB Input PSD
http://www.fmwconcepts.com/misc_tests/p ... a3srgb.psd

CMYK Input PSD
http://www.fmwconcepts.com/misc_tests/p ... a3cmyk.psd


test1.png from sRGB
Image

test2.png from CMYK
Image
Last edited by fmw42 on 2013-07-15T20:36:06-07:00, edited 1 time in total.
briandenks
Posts: 29
Joined: 2013-06-19T01:35:25-07:00
Authentication code: 6789

Re: PSD Conversion

Post by briandenks »

i guess frank that was why i jumped onto that other thread that was trying to achieve a similar thing take either cmyk or rgb and convert to one correctly...
regarding -colorspace i found adding this to any of the commands made the color terrible ( if you add -colorspace RGB to cmyk its bad and vice versa), i also hoped that IM would respect what its given in terms of colorspace ( not profile) and it DOES for jpg + tif ... however for png + gif + bmap it converts it to rgb ... so my quandry was how to ensure all is kept in the correct profile and colorspace as when its fed to IM...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PSD Conversion

Post by fmw42 »

see my examples above. PNG does not support cmyk and I do not know about BMP. I think GIF does but am not sure. It may need a profile.

Also IM does not like to process in CMYK, at least not without profiles.
Last edited by fmw42 on 2013-07-15T20:38:40-07:00, edited 1 time in total.
briandenks
Posts: 29
Joined: 2013-06-19T01:35:25-07:00
Authentication code: 6789

Re: PSD Conversion

Post by briandenks »

Ace, thanks for posting these, im still unsure how to implement your script on linux but should i test these files with the current setup ?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PSD Conversion

Post by fmw42 »

briandenks wrote:Ace, thanks for posting these, im still unsure how to implement your script on linux but should i test these files with the current setup ?

It is easy to create a bash shell script to take an image as input and return the output. The shell script can be called from a terminal window as

bash scriptname input output


or you can just change the infile in the commands above as I did and just copy and paste those commands in a bash terminal window.

The script can also be called from PHP exec() command.

The path to the profiles will need to be changed for your profile location.
briandenks
Posts: 29
Joined: 2013-06-19T01:35:25-07:00
Authentication code: 6789

Re: PSD Conversion

Post by briandenks »

Thanks fred, i opened up both PSD files in photoshop and you can immediately see the difference even though the file is very small (would this not be the same after conversion ? ie cmyk to rgb...
Photoshop shows the files as 'untagged' which is correct to my workflow ( thats what i refer to as not profiled)
briandenks
Posts: 29
Joined: 2013-06-19T01:35:25-07:00
Authentication code: 6789

Re: PSD Conversion

Post by briandenks »

fmw42 wrote: infile="zelda3srgb.psd"
colorspace=`convert $infile -format "%[colorspace]" info:`
if [ "$colorspace" = "sRGB" ]; then
convert $infile -resize 200% -profile /Users/fred/images/profiles/sRGB.icc test1.png
elif [ "$colorspace" = "CMYK" ]; then
convert $infile -profile /Users/fred/images/profiles/USWebCoatedSWOP.icc -profile /Users/fred/images/profiles/sRGB.icc -resize 200% test2.png
fi


infile="zelda3cmyk.psd"
colorspace=`convert $infile -format "%[colorspace]" info:`
if [ "$colorspace" = "sRGB" ]; then
convert $infile -resize 200% -profile /Users/fred/images/profiles/sRGB.icc test1.png
elif [ "$colorspace" = "CMYK" ]; then
convert $infile -profile /Users/fred/images/profiles/USWebCoatedSWOP.icc -profile /Users/fred/images/profiles/sRGB.icc -resize 200% test2.png
fi
Can this be presented as 'one liner' ? to encompass both formats on one line ?

eg: currently : -resample -strip -profile /path/to/icc - infile etc etc
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PSD Conversion

Post by fmw42 »

briandenks wrote:Thanks fred, i opened up both PSD files in photoshop and you can immediately see the difference even though the file is very small (would this not be the same after conversion ? ie cmyk to rgb...
Photoshop shows the files as 'untagged' which is correct to my workflow ( thats what i refer to as not profiled)
My script checks the colorspace of the image and converts to sRGB appropriately as IM determines whether it is CMYK or sRGB.

You have to be careful in PS that it does not add a profile when opening the images.

You can see from my output, that the conversion takes care of the CMYK conversion to sRGB so that the output in either case is a correct sRGB image with an sRGB profile.


When I open the two input images in PS, you can see a slight difference in coloration. The CMYK red is a bit darker. But that is how PS created them from the same common sRGB jpg.

I do not think you can do much better than this considering that you start with images with no profile.
briandenks
Posts: 29
Joined: 2013-06-19T01:35:25-07:00
Authentication code: 6789

Re: PSD Conversion

Post by briandenks »

Thanks Fred,
our files are fully built layered PS files not files created from a jpg... and yes i agree PS will try to color manage for you ... now if that means getting a 'warning' from pshop saying hey do you want to convert this to a profile or NOT COLOR MANAGE then yeah if you click DONT COLOR MANAGE the files open in PS as they left ..
Currently for us ( this is how im testing ) we take an existing PSD ( untagged cmyk) and pass it to IM using the following : +profile '*' -flatten -background white
We then use : -resample -strip -profile /usr/share/USWebCoatedSWOP.icc or -resize -strip -profile /usr/share/USWebCoatedSWOP.icc depending on what the user selects in the web app and this converts the file to png tif gif jpg bmp at the selected dpi or resolution.
We then download the jpg png tif and gif and open back up in pshop alongside the original psd to check for color.. its off the only one thats correct is the tif...
i notice the common difference on the files that are brighter are that the CMYK colorspace is not carried and IM strips the ALPHA out of the file ...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PSD Conversion

Post by fmw42 »

i notice the common difference on the files that are brighter are that the CMYK colorspace is not carried and IM strips the ALPHA out of the file ...
I am not sure why you are losing the alpha. Is that important? Note IM cannot handle both background transparency and alpha channel transparency. I suspect you are losing the transparency because it is background transparency and IM probably only processes alpha channel transparency.

As for the multilayer issue, you can modify my script to take the first layer (0 for IM) which is usually the flattened layer from PS.

So rather than

image.psd

you would use

image.psd[0]

in my script.

I think you need to do some tests with my commands and see if that solves your problem, since you cannot provide an example for me to use for testing.


Here is a modified version

infile="your.psd[0]"
colorspace=`convert $infile -format "%[colorspace]" info:`
if [ "$colorspace" = "sRGB" ]; then
convert $infile +profile *.ic* -resize 200% -profile /Users/fred/images/profiles/sRGB.icc test1.png
elif [ "$colorspace" = "CMYK" ]; then
convert $infile +profile *.ic* -profile /Users/fred/images/profiles/USWebCoatedSWOP.icc -profile /Users/fred/images/profiles/sRGB.icc -resize 200% test2.png
fi


You can change the -resize argument as desired or replace with -resample ...

I do not know what more to add to the discussion without some feedback or a real example from you. You can create some non-proprietary example psd and post a link to it.
briandenks
Posts: 29
Joined: 2013-06-19T01:35:25-07:00
Authentication code: 6789

Re: PSD Conversion

Post by briandenks »

hello Fred,
Thanks for your help over this past few weeks, its been eye opening !
just wanted to report back with some findings ....
Our untagged CMYK PSD files when being converted to RGB were being very very bright and not even close to the original PSD, we proved this by pushing a PSD into IM for thumbnail,resize and resample ... by looking at photoshops default colour settings ( black point compensation, 20% dot, dither etc) and its default color profile settings for RGB CMYK ive found what works for us in the colorspace -RGB (this IM version 6.6.9 is pre the change to -sRGB switch)

convert -resize +profile '*' -profile /path/to/icc/USWebCoatedSWOP.icc -profile /path/to/icc/sRGB_IEC61966-2-1_black_scaled.icc -black-point-compensation -intent Relative
convert -resample +profile '*' -profile /path/to/icc/USWebCoatedSWOP.icc -profile /path/to/icc/sRGB_IEC61966-2-1_black_scaled.icc -black-point-compensation -intent Relative
convert -thumbnail +profile '*' -profile /path/to/icc/USWebCoatedSWOP.icc -profile /path/to/icc/sRGB_IEC61966-2-1_black_scaled.icc -black-point-compensation -intent Relative
ive found the above settings 'mimic' the way photoshop defaults to handling color we get a visual match, it also seems to carry to other applications when the jpg png are used...


The files (png,tiff,jpg) when pushed through IM and opened back into photoshop are EXACTLY the same in color although due to only being able to assign -colorspace RGB the conversions do change colorspace which is an issue.
I have no idea why anyone would want a CMYK JPEG when its only use could be photoshop ! most browsers dont respect it ... But if these files went to a printer i guess they wouldnt be happy....?

if i added a <-strip> at the end of the command e.g. : -resize +profile '*' -profile /path/to/icc/USWebCoatedSWOP.icc -profile /path/to/icc/sRGB_IEC61966-2-1_black_scaled.icc -black-point-compensation -intent Relative -strip
would it remove the last profile so it would appear as not color managed ? would there be any advantage to removing the profile ? Im still concerned even though ive got a perfect match on screen and in photoshop that its not all what it seems and my lack of knowledge is letting me down, we have converted the colorspace from CMYK to RGB and visually it looks perfect, but of course its in a colorspace that what it never came from ...
Would printing from this converted RGB jpg against a print from the original CMYK PSD make any noticable difference ?
Post Reply