Cannot convert all pdf's

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?".
Post Reply
timmey21
Posts: 4
Joined: 2011-01-03T13:04:33-07:00
Authentication code: 8675308

Cannot convert all pdf's

Post by timmey21 »

Hi,

I'm not a proffesional with ImageMagick, but I want to convert a PDF to images (PHP). Code below works, but not with all pdf's.

Code: Select all

exec('/usr/bin/convert  -density 300 -quality 80 magazine.pdf page.jpg');
With some PDF's i get the following error: " **** Warning: CS/cs (setcolorspace) operand not a name: ..."

Does anybody know how i can fix this problem?

Tim
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Cannot convert all pdf's

Post by fmw42 »

the image withing the pdf is probably cmyk.

try adding -colorspace RGB before reading the image

exec('/usr/bin/convert -colorspace RGB -density 300 -quality 80 magazine.pdf page.jpg');

otherwise, you may need to use profiles

see

http://www.imagemagick.org/Usage/formats/#profiles
timmey21
Posts: 4
Joined: 2011-01-03T13:04:33-07:00
Authentication code: 8675308

Re: Cannot convert all pdf's

Post by timmey21 »

Thank you for your quick reaction! I tried to add -colorspace RGB but it has no effect.

I visited the link about profiles, but how can i see wich profile I need for my PDF?

EDIT: I only get the error when i use the -density option. But i need this option for a good quality of the image.
Last edited by timmey21 on 2011-01-05T12:16:48-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: Cannot convert all pdf's

Post by fmw42 »

what version of IM are you using and on what platform? perhaps you need to upgrade to fix your issue!

Your command works just fine for me (in command line IM) using IM 6.6.6.10 Q16 (hdri)


convert -density 300 -quality 80 magazine.pdf magazine.jpg

I get the first page of the pdf converted to a jpg
timmey21
Posts: 4
Joined: 2011-01-03T13:04:33-07:00
Authentication code: 8675308

Re: Cannot convert all pdf's

Post by timmey21 »

My host is using "ImageMagick 6.2.8 10/20/10 Q16". Can that be the problem?

I will ask my host for an update.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Cannot convert all pdf's

Post by fmw42 »

IM 6.2.8 is very very old (over 350 versions old). So many things have been changed and improved and many bugs fixed. So upgrade if at all possible. Otherwise, I know of no other solution. But perhaps the IM developers can be more specific.
timmey21
Posts: 4
Joined: 2011-01-03T13:04:33-07:00
Authentication code: 8675308

Re: Cannot convert all pdf's

Post by timmey21 »

Thank you very much!! The version was the problem, now it's working perfect :D
Post Reply