Page 1 of 1
Color changes when converting PDF to JPG using PHP
Posted: 2015-07-22T15:55:02-07:00
by kjbasiljohn
When I am converting PDF to JPG using PHP and Command, the color is changing.
Following command are using
convert -limit memory 0 -limit map 0 -quiet -define pdf:use-cropbox=true -interlace none -density 300x300 +repage "source" "destination"
Original PDF
http://basiljohn.com/test/0315+EA+Autumn+4.pdf
Image
http://basiljohn.com/test/7664-max.jpg
Image
http://basiljohn.com/test/7666-max.jpg
Any help please?
Re: Color changes when converting PDF to JPG using PHP
Posted: 2015-07-22T15:56:44-07:00
by kjbasiljohn
ImageMagick version using v6.8.4-10
Re: Color changes when converting PDF to JPG using PHP
Posted: 2015-07-22T17:17:17-07:00
by fmw42
There were changes to IM around 6.8.x that may be affecting your processing. You might upgrade to the current version.
My system will not let me go to the place you have uploaded your images, saying "High Risk Website Blocked". Perhaps you should upload your images to dropbox.com.
Re: Color changes when converting PDF to JPG using PHP
Posted: 2015-07-22T17:25:07-07:00
by kjbasiljohn
Re: Color changes when converting PDF to JPG using PHP
Posted: 2015-07-22T18:55:19-07:00
by 246246
Your input pdf is CMYK. Output is RGB.
Current release of ImageMagick (6.9.1-9) does not change colorspace with your command, i.e. CMYK jpg is generated. So if you want CMYK jpg, upgrade is recommended.
Re: Color changes when converting PDF to JPG using PHP
Posted: 2015-07-22T19:02:07-07:00
by fmw42
Your input PDF is CMYK, you probably need to convert it to sRGB with profiles when saving to JPG.
Try this (unix syntax) for the first page. It works for me on IM 6.9.1.9 Q16 Mac OSX
Code: Select all
convert 0315+EA+Autumn+4.pdf[0] \
-profile /Users/fred/images/profiles/USWebCoatedSWOP.icc \
-profile /Users/fred/images/profiles/sRGB.icc \
test_srgb.jpg
use your own path to these profiles.
Please always identify your version of IM and platform. Your version of IM may be too old or buggy to do the convert to CMYK JPG. So you may need an upgrade.
On my Mac OSX with IM 6.9.1.9, a direct conversion looks color inverted when displayed as per the following command line. This is often an issue with CMYK JPG
Code: Select all
convert 0315+EA+Autumn+4.pdf[0] 0315+EA+Autumn+4_0.jpg
So I would stick with the profile conversion to sRGB as the safest measure. Some viewers do not handle CMYK JPEG very well.
Re: Color changes when converting PDF to JPG using PHP
Posted: 2015-07-22T19:45:24-07:00
by fmw42
This may also work, but the profile method gives more accurate colors.
Code: Select all
convert -colorspace sRGB 0315+EA+Autumn+4.pdf[0] test_srgb2.jpg
Re: Color changes when converting PDF to JPG using PHP
Posted: 2015-07-22T20:59:28-07:00
by kjbasiljohn
Thank you so much, its much better now. I have used following command.
convert -limit memory 0 -limit map 0 -quiet -define pdf:use-cropbox=true -interlace none -background white -alpha remove -density 300x300 +repage -colorspace sRGB " SOURCE -quality 95 jpg:" DESTINATION;
can you please tell me from where i can download, sRGB.icc
Thank You
Re: Color changes when converting PDF to JPG using PHP
Posted: 2015-07-22T21:03:36-07:00
by snibgo
Look in the directory that contains your convert program.
Re: Color changes when converting PDF to JPG using PHP
Posted: 2015-07-22T22:15:37-07:00
by fmw42
snibgo wrote:Look in the directory that contains your convert program.
I do not think they are there by default. I think they must be installed. At least that is how it is on my Mac. Neither the IM download folder nor my folder that contains the installed convert program have profiles located there.
I installed them from:
Get them from profiles.zip at
http://www.imagemagick.org/download/delegates/
or
http://www.mattbeals.com/icc/
or for just sRGB.icc, you can get it at
http://www.color.org/srgbprofiles.xalter
Re: Color changes when converting PDF to JPG using PHP
Posted: 2015-07-23T05:22:59-07:00
by snibgo
Thanks for the correction. sRGB.icc is provided with the IM installation on Windows, but may not be with other installations.
Re: Color changes when converting PDF to JPG using PHP
Posted: 2015-07-23T09:36:38-07:00
by fmw42
snibgo wrote:Thanks for the correction. sRGB.icc is provided with the IM installation on Windows, but may not be with other installations.
Perhaps that is the case with all binaries, but not when installing from source?
Re: Color changes when converting PDF to JPG using PHP
Posted: 2015-07-23T13:40:21-07:00
by kjbasiljohn
Thank you so much guys for all the help. I didn't try with profiles yet. I will let you know once after I have used that.