Page 1 of 1

PDF to image conversion not working in php

Posted: 2012-10-30T02:59:13-07:00
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.

Re: PDF to image conversion not working in php

Posted: 2012-10-30T10:31:47-07:00
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?

Re: PDF to image conversion not working in php

Posted: 2012-10-30T10:37:39-07:00
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

Re: PDF to image conversion not working in php

Posted: 2012-10-30T10:46:01-07:00
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.

Re: PDF to image conversion not working in php

Posted: 2012-10-30T10:50:10-07:00
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?

Re: PDF to image conversion not working in php

Posted: 2012-10-30T14:46:21-07:00
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.

Re: PDF to image conversion not working in php

Posted: 2012-11-01T04:15:31-07:00
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

Re: PDF to image conversion not working in php

Posted: 2015-08-04T22:24:49-07:00
by ashish1521
so was the problem resolved finally?

I need help regarding the same..

Re: PDF to image conversion not working in php

Posted: 2015-08-04T23:44:10-07:00
by fmw42
Your PHP may need to have its PATH modified to find GS as well as IM.

Re: PDF to image conversion not working in php

Posted: 2016-04-25T09:19:54-07:00
by handellphp
got the same problem, Imagemagick can convert every file type except for PDF.
Any suggestions?