PDF to image conversion not working in php

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
GenericUser813
Posts: 7
Joined: 2010-10-06T02:11:18-07:00
Authentication code: 8675308

PDF to image conversion not working in php

Post by GenericUser813 »

Hello, i formated my server with w7 64 and did clean imagick and ghostscript install, both latest 64b versions.

When i try to load up new image with "new imagick('image.jpg')" it works no problem, but when i try to load pdf file i get

Code: Select all

exception 'ImagickException' with message 'PostscriptDelegateFailed `C:/Windows/TEMP/magick-rR4d9aY4': No such file or directory @ error/pdf.c/ReadPDFImage/645' in D:\wwwl\img.php:76 Stack trace: #0 D:\wwwl\img.php(76): Imagick->__construct('upload/p2.pdf') #1 {main}
At first i thought there was a problem with ghostscript, but when i try to run the conversion from cmd.exe command line: "convert -scale 165 abc.pdf abc.png" it works like a charm.
I also tried to replace the "new imagick()" part in my php file with exec("convert -scale 165 abc.pdf abc.png"), but that isn't working either.

I just can't seem to figure out what i'm doing wrong.

edit: This was maybe supposed to go into the imagick section.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PDF to image conversion not working in php

Post by fmw42 »

It is possible that IM is not seeing GS. type

convert -list configure

look at the line starting with DELEGATES. Does it include gs?
GenericUser813
Posts: 7
Joined: 2010-10-06T02:11:18-07:00
Authentication code: 8675308

Re: PDF to image conversion not working in php

Post by GenericUser813 »

I don't think so

Code: Select all

Name          Value
-----------------------------------------------------------------------------
CC            vs10
COPYRIGHT     Copyright (C) 1999-2012 ImageMagick Studio LLC
DELEGATES     bzlib freetype jpeg jp2 lcms png tiff x11 xml wmf zlib
FEATURES      OpenMP
HOST          Windows
LIB_VERSION   0x680
LIB_VERSION_NUMBER 6,8,0,1
NAME          ImageMagick
RELEASE_DATE  2012-11-01
VERSION       6.8.0
WEBSITE       http://www.imagemagick.org
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PDF to image conversion not working in php

Post by fmw42 »

Your Ghostscript was not correctly installed or your did not install IM afterwards from source. Or you installed GS in some other place than IM is looking for it.
GenericUser813
Posts: 7
Joined: 2010-10-06T02:11:18-07:00
Authentication code: 8675308

Re: PDF to image conversion not working in php

Post by GenericUser813 »

I used this installer http://www.imagemagick.org/download/bin ... 64-dll.exe and this one for ghostscript (Ghostscript 9.06 for Windows (64 bit) ) http://downloads.ghostscript.com/public/gs906w64.exe i installed them into their default paths.

But if imagick can't find the ghostscript, how is it possible that command started manually from commandline (convert -scale 165 abc.pdf abc.png) works with no problems?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PDF to image conversion not working in php

Post by fmw42 »

Sorry I am not a Windows user or expert. Perhaps some Windows user may be able to help.

Does

convert -list configure

show gs when run from the command line?

Is it possible that PHP does not know where GS is installed.
GenericUser813
Posts: 7
Joined: 2010-10-06T02:11:18-07:00
Authentication code: 8675308

Re: PDF to image conversion not working in php

Post by GenericUser813 »

So i partially solved the problem by instaling the 32b version of the ghoscript and i can at least make it work from exec command line.
But there is new problem which popped up, i updated my php to 5.4.8 version and my php_imagick.dll extension is not working anymore and i can't seem to be able to find one which works with php ts 5.4.8 32b vc9
ashish1521
Posts: 1
Joined: 2015-08-04T22:18:46-07:00
Authentication code: 1151

Re: PDF to image conversion not working in php

Post by ashish1521 »

so was the problem resolved finally?

I need help regarding the same..
Ashish Gupta
PHP Application Dev
Best Web Browser
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: PDF to image conversion not working in php

Post by fmw42 »

Your PHP may need to have its PATH modified to find GS as well as IM.
handellphp
Posts: 1
Joined: 2016-04-25T09:16:27-07:00
Authentication code: 1151

Re: PDF to image conversion not working in php

Post by handellphp »

got the same problem, Imagemagick can convert every file type except for PDF.
Any suggestions?
Post Reply