Page 1 of 1

Convert CMYK PDF to JPG creates corrupt image.

Posted: 2010-02-10T04:30:55-07:00
by atw
Hi guys,

I am trying to convert PDFs to JPGs on a LAMP (Linux, Apache, MySQL, PHP) server using this command:

Code: Select all

exec("convert test.pdf[0] -density 100 -sample 200x200 test.jpg");
This works brilliantly, most of the time. However, sometimes the results are less than desirable:
Image
Should look like this:
Image

The only difference between the results you see above is that I exported the first as High Quality Print and Press Quality from InDesign CS3 and the second one is exported as Smallest File Size from the same InDesign.

Obviously, they are of different file sizes but that doesn't seem to be the cause.

I believe it is caused by the first two being CMYK and the working one being RGB.

I do not know which version of ImageMagick is installed (or how to find out).

Please help. :)

---

Versions:

I have figured out how to determine the versions...

ImageMagick Convert ("convert -version"):

Code: Select all

ImageMagick 6.2.8 04/17/08 Q16 file:/usr/share/ImageMagick-6.2.8/doc/index.html Copyright: Copyright (C) 1999-2006 ImageMagick Studio LLC
GhostScript ("gs -h"):

Code: Select all

ESP Ghostscript 8.15.2 (2006-04-19)
Copyright (C) 2004 artofcode LLC, Benicia, CA.  All rights reserved.

Re: Convert CMYK PDF to JPG creates corrupt image.

Posted: 2010-02-10T09:20:23-07:00
by snibgo
You might install a versions that are less than four year old, and see if you still have the problem.

Re: Convert CMYK PDF to JPG creates corrupt image.

Posted: 2010-02-10T11:09:07-07:00
by atw
snibgo wrote:You might install a versions that are less than four year old, and see if you still have the problem.
lol

I am in the process of trying to get the hosting company to update/upgrade the software :)

But they are SO SLOW :(

Re: Convert CMYK PDF to JPG creates corrupt image.

Posted: 2010-02-10T11:09:38-07:00
by fmw42
try

exec("convert -colorspace rgb test.pdf[0] -density 100 -sample 200x200 test.jpg");

Re: Convert CMYK PDF to JPG creates corrupt image.

Posted: 2010-02-11T03:35:24-07:00
by atw
fmw42 wrote:try

exec("convert -colorspace rgb test.pdf[0] -density 100 -sample 200x200 test.jpg");
Sorry fmw42, unfortunately your suggestion didn't fix the problem. Thank you for the suggestion though...

Re: Convert CMYK PDF to JPG creates corrupt image.

Posted: 2010-02-11T09:43:02-07:00
by fmw42
suggest you post one of your images that causes problems so someone can see if it is corrupt in some way or test on a different IM.

Re: Convert CMYK PDF to JPG creates corrupt image.

Posted: 2010-02-15T09:22:39-07:00
by atw
Hi,

I have spoken to the hosting providers and the installed versions are the current versions from the Linux distro's repositories :(

I have asked them to install from source or use the RPMs shown on this site but I suspect that they will refuse.

Is there an alternative which does not require installation (Java based maybe)?

Re: Convert CMYK PDF to JPG creates corrupt image.

Posted: 2010-02-15T10:14:28-07:00
by atw
fmw42 wrote:suggest you post one of your images that causes problems so someone can see if it is corrupt in some way or test on a different IM.
Sorry, newbie question alert. How would I attach a PDF to this board?

Re: Convert CMYK PDF to JPG creates corrupt image.

Posted: 2010-02-15T15:25:52-07:00
by snibgo
Put it on a website somewhere and post the URL here.

Re: Convert CMYK PDF to JPG creates corrupt image.

Posted: 2010-02-17T16:17:58-07:00
by atw
No need.

I just finished creatine a VMware VM of Ubuntu 9.10 Server with LAMP, SSH, Samba and ImageMagick (the current version) and quess what; yep, it worked perfectly with the exact same PDF (the colour was a little off--suggesting that the PDF is, indeed CMYK).

This leaves me in the rather unfortunate situation that I cannot get the new version installed on the hosting package.

Is there an alternative way to proceed (maybe something similar to ImageMagick/GhostScript but Java based)? Or perhaps a good reputable RPM repository which host the appropriate RPMs for CentOS 5 64-bit...?

Any suggestions gratefully recieved...

Many thanks.

Re: Convert CMYK PDF to JPG creates corrupt image.

Posted: 2010-05-20T11:46:30-07:00
by LooInSpain
I'm using the same version of IM and Ghostscript on a shared server and was having the same problem. I managed to get around this with this command in IM:

Code: Select all

exec("convert -colorspace rgb -units PixelsPerInch -density 150x150 pdf/Serie-Irta.pdf  pdf/Serie-Irta.jpg");
Now instead of the jpg output like you showed in the first post, the pdf's convert pretty well. Not as good quality as with a later version of IM, but at least they are now converting.