PHP CMYK to sRGB - JPG Images not keeping true colors
PHP CMYK to sRGB - JPG Images not keeping true colors
Hi all,
I've been trying to convert CMYK images from a PDF to sRGB for web display (since they're smaller). I get perfect color rendering when the output is CMYK, but when using sRGB colorspace ($img->setImageColorspace(Imagick::COLORSPACE_SRGB)) I do not get true colors. Essentially, everything brighter and more "Neon-y".
I've tried tons of combinations of code samples and none have solved the problem. I've download and tried a number of color profiles and that has not worked either.
If I open the CMYK jpg and change the color profile to RGB in photoshop, the result is perfect. However, I need to use Imagick for a workflow system that will convert numerous pages of out.
Can anyone help me understand what is going on and how to solve the problem. I've attached the good CMYK and my RGB output
I've been trying to convert CMYK images from a PDF to sRGB for web display (since they're smaller). I get perfect color rendering when the output is CMYK, but when using sRGB colorspace ($img->setImageColorspace(Imagick::COLORSPACE_SRGB)) I do not get true colors. Essentially, everything brighter and more "Neon-y".
I've tried tons of combinations of code samples and none have solved the problem. I've download and tried a number of color profiles and that has not worked either.
If I open the CMYK jpg and change the color profile to RGB in photoshop, the result is perfect. However, I need to use Imagick for a workflow system that will convert numerous pages of out.
Can anyone help me understand what is going on and how to solve the problem. I've attached the good CMYK and my RGB output
- Attachments
-
- this is correct, converted to RGB in photoshop
- EvilErnie_04_Page_08-copy.jpg (456.34 KiB) Viewed 18070 times
-
- this is what I get using imagick
- EvilErnie_04_Page_08.jpg (354.24 KiB) Viewed 18070 times
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PHP CMYK to sRGB - JPG Images not keeping true colors
set the colorspace to sRGB before reading the input image -- at least that is what is done in command line.
Re: PHP CMYK to sRGB - JPG Images not keeping true colors
I changed my code to this:
$img = new imagick();
$img->setResolution(300, 300);
$img->setImageColorspace(Imagick::COLORSPACE_SRGB);
$img->readImage($file_name);
and I get this:
Can not process empty Imagick object
It seems to only work after I read the images in
$img = new imagick();
$img->setResolution(300, 300);
$img->setImageColorspace(Imagick::COLORSPACE_SRGB);
$img->readImage($file_name);
and I get this:
Can not process empty Imagick object
It seems to only work after I read the images in
Re: PHP CMYK to sRGB - JPG Images not keeping true colors
I even attempted to run my code to change the exported CMYK jpgs to RGB using Imagemagick on the command line (setting color space to RGB) and the output is exactly the same as if I run my php code.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PHP CMYK to sRGB - JPG Images not keeping true colors
I am not an Imagick expert. But you can try to use profiles to do the colorspace change.
Re: PHP CMYK to sRGB - JPG Images not keeping true colors
Already tried that many times with many profiles. Also, tried creating my own CMYK jpg and using commandline to change it to RGB and the color changed just like before. Ill play around with the profiles so more but this seems to be a fundamental problem with how Imagemagick is transposing CMYK colors to the RGB scheme. Believe me, I know nothing about graphics so this is my best guess. I'm a coder by trade.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PHP CMYK to sRGB - JPG Images not keeping true colors
Perhaps you should extract the actual image from the PDF first, then change colorspace. IM cannot do that, but there are tools that can. See http://www.imagemagick.org/Usage/formats/#ps. Also if you post your pdf original, some one can test converting it in command line (or you can do that). Then just use PHP exec() to do the processing rather than Imagick. Imagick does not have the full functionality as Imagemagick and Imagick does not seem to be maintained very well.
Re: PHP CMYK to sRGB - JPG Images not keeping true colors
I've been thinking of migrating to the PHP exec() formatted code but I have everything written the other way. I'll play around with it. Also, I'll see about getting my PDF posted.
question: do you know how I can install and confirm the installation of LCMS. I'm getting the impression that could be part of my problem as well.
question: do you know how I can install and confirm the installation of LCMS. I'm getting the impression that could be part of my problem as well.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PHP CMYK to sRGB - JPG Images not keeping true colors
I am on a Mac. So I just use MacPorts to install all my delegates, then install IM from source. I do not know how to link it to Imagick (if that is needed?)
Try the command line (in exec if you do not have terminal access) and see if your command works. If not, then you may have a missing delegate (LCMS?). Be sure to use LCMS 2.
convert -version will tell you if you have lcms installed.
convert -versions
Version: ImageMagick 6.9.1-7 Q16 x86_64 2015-07-05 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules
Delegates (built-in): bzlib cairo fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms lqr ltdl lzma openexr png ps rsvg tiff webp x xml zlib
Try the command line (in exec if you do not have terminal access) and see if your command works. If not, then you may have a missing delegate (LCMS?). Be sure to use LCMS 2.
convert -version will tell you if you have lcms installed.
convert -versions
Version: ImageMagick 6.9.1-7 Q16 x86_64 2015-07-05 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules
Delegates (built-in): bzlib cairo fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms lqr ltdl lzma openexr png ps rsvg tiff webp x xml zlib
Re: PHP CMYK to sRGB - JPG Images not keeping true colors
I have Mac OS as well. When I run convert -list configure | grep -i "delegates", I see
DELEGATES bzlib mpeg freetype jng jpeg lzma png tiff xml zlib
However, LCMS 2 is definitely installed.
DELEGATES bzlib mpeg freetype jng jpeg lzma png tiff xml zlib
However, LCMS 2 is definitely installed.
Re: PHP CMYK to sRGB - JPG Images not keeping true colors
Doing what you suggested:
convert -versions
Version: ImageMagick 6.9.1-7 Q16 x86_64 2015-07-06 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib
convert -versions
Version: ImageMagick 6.9.1-7 Q16 x86_64 2015-07-06 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PHP CMYK to sRGB - JPG Images not keeping true colors
IM is not seeing it. How did you install IM?
convert -list configure | grep -i "delegates"
DELEGATES bzlib mpeg fftw fontconfig freetype gslib jbig jng jpeg lcms lqr lzma openexr openjp2 png ps rsvg tiff webp x xml zlib
See my post at viewtopic.php?f=1&t=21502&p=88202&hilit ... rts#p88202, if you want to use MacPorts for your delegates and install IM manually from source.
convert -list configure | grep -i "delegates"
DELEGATES bzlib mpeg fftw fontconfig freetype gslib jbig jng jpeg lcms lqr lzma openexr openjp2 png ps rsvg tiff webp x xml zlib
See my post at viewtopic.php?f=1&t=21502&p=88202&hilit ... rts#p88202, if you want to use MacPorts for your delegates and install IM manually from source.
Re: PHP CMYK to sRGB - JPG Images not keeping true colors
I've always done everything with homebrew. I just uninstalled and reinstalled IM with Little-cms. Same problem. Ill give your suggestion a try!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PHP CMYK to sRGB - JPG Images not keeping true colors
Try with LCMS 2. Also are you installing IM from Homebrew or from source? If the former, you may need to install IM and LCMS together. Sorry, I do not know Homebrew.
Re: PHP CMYK to sRGB - JPG Images not keeping true colors
I'm doing it from homebrew. And I keep trying to uninstall and reinstall IM with LCMS2 but even though it appears to work, the delegates never update.