We are trying to read in images uploaded by potential customers, convert them to PNG, and output the image on the screen for the customer to manipulate size and position on a t-shirt.
The problem we're running into is CMYK files. Whenever we convert to PNG, we have loss of color. We know the colorspace is being automatically converted to RGB since PNG only supports RGB.
However, when we convert CMYK files to JPG to allow the colorspace to remain the same, we still have color shift. Again, this only happens when using CMYK source files.
This problem is not happening when we use RGB source files.
We did a test with a color chart image we grabbed off the web. Here is the source file we're using (we've tried it with several different source formats all with the same results):
CMYK PDF Color Chart
And here are some of the outputs we've tried:
Convert to JPG (and allow colorspace to remain CMYK) - convert ColorChartCMYK.pdf -colorspace CMYK ColorChartCMYK.pdf.cmyk.jpg
Convert to JPG (convert to RGB) - convert ColorChartCMYK.pdf -colorspace RGB ColorChartCMYK.pdf.rgb.jpg
Convert to PNG - convert ColorChartCMYK.pdf ColorChartCMYK.pdf.png
As you can see, all the results look the same - just off enough to be noticeable. Unfortunately, we're not really knowledgeable when it comes to digital image formats so we could be doing something completely wrong. One option we have is to just tell customers they have to use RGB images, but we'd like to allow any formats we can make work.
Thanks in advance!
Conversion Problems from CMYK
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Conversion Problems from CMYK
How do you know? What you mean is, when you view the CMYK file with one program that converts from CMYK to RGB for the screen, you get a different result from viewing an RGB file created by ImageMagick. Both programs are converting from CMYK to RGB, but you don't know which one is "more correct".Whenever we convert [from CMYK] to PNG, we have loss of color.
Of course, the t-shirt printer uses CYMK inks, so I hope you are not converting files to RGB then back to CMYK, with the loss of color fidelity that would bring. I expect you are only converting temporarily to PNG so you can show an approximation on the screen (approximate, because the gamuts of screen and printers are different), and you are using the customer's CMYK file directly for the printing.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Conversion Problems from CMYK
try
convert -colorspace RGB image.pdf image.png
convert -colorspace RGB image.pdf image.png
Re: Conversion Problems from CMYK
I don't think that the former commandline will yield better results here. On my system, I get worse colors by that (as ImageMagick omits the -dUseCIEColor parameter for Ghostscript).
@tsdesigns: What versions of ImageMagick and Ghostscript are you using? Because I get (with the current versions) a bit better colors than you - with the standard commandline "convert ColorChartCMYK.pdf output.png".
But your PDF file is not the best example - as it's of low quality (and many 'CMYK to RGB and back' conversions are involved!) - and for PDFs, ImageMagick has to rely on Ghostscript. You can get ok colors by directly using Ghostscript commands (also possible by editing the ImageMagick delegates), but it's more difficult here. (The result should probably look like this.)
Do you have a lot of PDFs to convert? If you have mostly TIFs for example, it will be easier. With a CMYK TIF (color profile included - the ideal case), the following ImageMagick commandline works:
convert input.tif -profile sRGB.icm output.png
See also the given link about color profiles.
@tsdesigns: What versions of ImageMagick and Ghostscript are you using? Because I get (with the current versions) a bit better colors than you - with the standard commandline "convert ColorChartCMYK.pdf output.png".
But your PDF file is not the best example - as it's of low quality (and many 'CMYK to RGB and back' conversions are involved!) - and for PDFs, ImageMagick has to rely on Ghostscript. You can get ok colors by directly using Ghostscript commands (also possible by editing the ImageMagick delegates), but it's more difficult here. (The result should probably look like this.)
Do you have a lot of PDFs to convert? If you have mostly TIFs for example, it will be easier. With a CMYK TIF (color profile included - the ideal case), the following ImageMagick commandline works:
convert input.tif -profile sRGB.icm output.png
See also the given link about color profiles.
Re: Conversion Problems from CMYK
ImageMagick includes a Ghostscript control file which includes this setting:
- <</UseCIEColor true>>
Re: Conversion Problems from CMYK
Yes, the -dUseCIEColor setting will be used with the standard command "convert ColorChartCMYK.pdf output.png" here. Thus, I get this. (As I said, I get a bit better colors than tsdesigns.)
By the way: Where can I find that Ghostscript control file?
But anyway.. It's still a very roughly conversion, I think.
For very good PDF/EPS CMYK to RGB conversion (depends on the source material, of course), one has to use something like this:
gs -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=2 -sDEVICE=tiff32nc -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r72 -sOUTPUTFILE=output.tif input.pdf
convert output.tif -profile CMYK.icc -profile sRGB.icm output.png
(Again the result - here also 'upsized' to 72dpi for a better comparison.)
By the way: Where can I find that Ghostscript control file?
But anyway.. It's still a very roughly conversion, I think.
For very good PDF/EPS CMYK to RGB conversion (depends on the source material, of course), one has to use something like this:
gs -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=2 -sDEVICE=tiff32nc -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r72 -sOUTPUTFILE=output.tif input.pdf
convert output.tif -profile CMYK.icc -profile sRGB.icm output.png
(Again the result - here also 'upsized' to 72dpi for a better comparison.)
Re: Conversion Problems from CMYK
Hi Everyone, thanks for the responses! I apologize for how long it's taken me to get back to this thread; I got pulled off this project temporarily and will be sifting through this information in the next week or so to see if we can get any further and will respond with additional questions as necessary.
The one question I can answer directly right now: Drarakel - we are using the latest stable version of ImageMagick. We installed it a few days before I posted this topic.
Again, I'm unfortunately completely green when it comes to this stuff, so I appreciate the help!
The one question I can answer directly right now: Drarakel - we are using the latest stable version of ImageMagick. We installed it a few days before I posted this topic.
Again, I'm unfortunately completely green when it comes to this stuff, so I appreciate the help!
Re: Conversion Problems from CMYK
And Ghostscript?tsdesigns wrote:we are using the latest stable version of ImageMagick.