Hello,
I am having problems getting any result out of a PDF to JPG conversion. Everything on the host unix side (shared hostgator) appears to be in order. http://www.indigrip.com/info.php will show all the host side settings.
The kind folks at hostgator also indicated the following: "verified both image magick and ghost scripting executables are in the same path: [root@gator1193 ~]# which convert; which gs /usr/bin/convert /usr/bin/gs".
Works with .jpg, .png, .svg, .gif but not .pdf.
PHP command: exec("convert test.pdf -colorspace RGB -geometry 200 output.jpg");
Result was nothing, not even an error message.
I found a debug snippet (thanks rubblewebs.co.uk) and modified PHP command to:
echo "<pre>";
exec("convert test.pdf output.jpg 2>&1", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
This change did provide some debug error results:
Array
(
[0] => CRIT: rangecheck in .setuserparams
[1] => Operand stack:
[2] => --nostringval-- --nostringval-- --nostringval--
[3] => convert: Postscript delegate failed `test.pdf': @ error/pdf.c/ReadPDFImage/645.
[4] => convert: missing an image filename `output.jpg' @ error/convert.c/ConvertImageCommand/2970.
)
All works on my local site, but after 3 days of researching/debugging, I can't find a solution. My host provider is willing to work on the issue on the server side, but like me, are not sure where to look.
Any advice would be appreciated.
-PA
convert PDF to JPG on Unix no results
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert PDF to JPG on Unix no results
You may need to provide the full path to convert and/or the full path to your images. Also when IM is compiled from source, one needs to pre-compile the delegate libraries for jpg, tiff, png, gs etc. I don't know if your host compiled it from source or just installed a binary.PHP command: exec("convert test.pdf -colorspace RGB -geometry 200 output.jpg");
Result was nothing, not even an error message.
The typical path to convert is
/usr/local/bin/convert
or sometimes
/usr/bin/convert
Your hosting provider should know.
try your PHP command with
convert -version
and confirm if you have the correct path. Then try
convert -list configure
and be sure gs shows in the line starting with DELEGATES to be sure IM recognizes where it is located.
My suspicion is that IM cannot find GS.
Re: convert PDF to JPG on Unix no results
Hi fmw42,
Thanks for the reply...the host server side shows what apears to be the correct correlation, does this provide any other insight?
system ("convert -list Configure")
Path: /usr/lib/ImageMagick-6.6.3/config/configure.xml
Name Value
-------------------------------------------------------------------------------
CC gcc -std=gnu99 -std=gnu99
CFLAGS -O2 -g -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -Wall -pthread
CONFIGURE ./configure '--host=i686-redhat-linux-gnu' '--build=i686-redhat-linux-gnu' '--target=i386-redhat-linux' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--enable-shared' '--disable-static' '--with-modules' '--with-perl' '--with-x' '--with-threads' '--with-magick_plus_plus' '--with-gslib' '--with-wmf' '--with-lcms' '--with-rsvg' '--disable-openmp' '--with-xml' '--with-perl-options=INSTALLDIRS=vendor CC='\''gcc -L/usr/src/redhat/BUILD/ImageMagick-6.6.3-0/magick/.libs'\'' LDDLFLAGS='\''-shared -L/usr/src/redhat/BUILD/ImageMagick-6.6.3-0/magick/.libs'\''' '--without-dps' '--without-included-ltdl' '--with-ltdl-include=/usr/include' '--with-ltdl-lib=/usr/lib' 'build_alias=i686-redhat-linux-gnu' 'host_alias=i686-redhat-linux-gnu' 'target_alias=i386-redhat-linux' 'CFLAGS=-O2 -g -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables' 'CXXFLAGS=-O2 -g -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables'
COPYRIGHT Copyright (C) 1999-2010 ImageMagick Studio LLC
CPPFLAGS -I/usr/include/ImageMagick
CXX g++
CXXFLAGS -O2 -g -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -pthread
DEFS -DHAVE_CONFIG_H
DELEGATES bzlib djvu fontconfig freetype gs jpeg jng jp2 lcms mpeg png rsvg tiff x11 xml wmf zlib
DISTCHECK_CONFIG_FLAGS 'CFLAGS=-O2 -g -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables' --disable-deprecated --with-quantum-depth=16 --with-umem=no --with-autotrace=no --with-dps=no --with-fontpath=
EXEC-PREFIX /usr
HOST i686-redhat-linux-gnu
LDFLAGS -L/usr/lib
LIB_VERSION 0x663
LIB_VERSION_NUMBER 6,6,3,0
LIBS -lMagickCore -llcms -ltiff -lfreetype -ljpeg -lfontconfig -lXext -lSM -lICE -lX11 -lXt -lbz2 -lz -lm -lpthread -lltdl
NAME ImageMagick
PCFLAGS
PREFIX /usr
QuantumDepth 16
RELEASE_DATE 2010-07-13
VERSION 6.6.3
WEBSITE http://www.imagemagick.org
Thanks for the reply...the host server side shows what apears to be the correct correlation, does this provide any other insight?
system ("convert -list Configure")
Path: /usr/lib/ImageMagick-6.6.3/config/configure.xml
Name Value
-------------------------------------------------------------------------------
CC gcc -std=gnu99 -std=gnu99
CFLAGS -O2 -g -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -Wall -pthread
CONFIGURE ./configure '--host=i686-redhat-linux-gnu' '--build=i686-redhat-linux-gnu' '--target=i386-redhat-linux' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--enable-shared' '--disable-static' '--with-modules' '--with-perl' '--with-x' '--with-threads' '--with-magick_plus_plus' '--with-gslib' '--with-wmf' '--with-lcms' '--with-rsvg' '--disable-openmp' '--with-xml' '--with-perl-options=INSTALLDIRS=vendor CC='\''gcc -L/usr/src/redhat/BUILD/ImageMagick-6.6.3-0/magick/.libs'\'' LDDLFLAGS='\''-shared -L/usr/src/redhat/BUILD/ImageMagick-6.6.3-0/magick/.libs'\''' '--without-dps' '--without-included-ltdl' '--with-ltdl-include=/usr/include' '--with-ltdl-lib=/usr/lib' 'build_alias=i686-redhat-linux-gnu' 'host_alias=i686-redhat-linux-gnu' 'target_alias=i386-redhat-linux' 'CFLAGS=-O2 -g -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables' 'CXXFLAGS=-O2 -g -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables'
COPYRIGHT Copyright (C) 1999-2010 ImageMagick Studio LLC
CPPFLAGS -I/usr/include/ImageMagick
CXX g++
CXXFLAGS -O2 -g -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -pthread
DEFS -DHAVE_CONFIG_H
DELEGATES bzlib djvu fontconfig freetype gs jpeg jng jp2 lcms mpeg png rsvg tiff x11 xml wmf zlib
DISTCHECK_CONFIG_FLAGS 'CFLAGS=-O2 -g -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables' --disable-deprecated --with-quantum-depth=16 --with-umem=no --with-autotrace=no --with-dps=no --with-fontpath=
EXEC-PREFIX /usr
HOST i686-redhat-linux-gnu
LDFLAGS -L/usr/lib
LIB_VERSION 0x663
LIB_VERSION_NUMBER 6,6,3,0
LIBS -lMagickCore -llcms -ltiff -lfreetype -ljpeg -lfontconfig -lXext -lSM -lICE -lX11 -lXt -lbz2 -lz -lm -lpthread -lltdl
NAME ImageMagick
PCFLAGS
PREFIX /usr
QuantumDepth 16
RELEASE_DATE 2010-07-13
VERSION 6.6.3
WEBSITE http://www.imagemagick.org
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert PDF to JPG on Unix no results
Your delegates shows that IM does indeed find GS. So I don't know what else to suggest. You will need a response from someone who knows more about IM configuration than I. Sorry. That was all I could suggest.
Do you have a way to run this without PHP via SSH or some access to the terminal? If so, that would let you know whether it was IM or PHP that is the issue.
One other thing that may be the problem. You don't have gs fonts installed. If there are no gs fonts, then gs may not work.
In my convert -list configure, I have
'--with-gs-font-dir=/opt/local/share/ghostscript/fonts/'
When your hosting provider installed GS, they perhaps forgot to install the fonts or did not put that (--with-gs-font-dir=...) into the IM ./configure command to tell GS and IM where the gs fonts are located.
Do you have a way to run this without PHP via SSH or some access to the terminal? If so, that would let you know whether it was IM or PHP that is the issue.
One other thing that may be the problem. You don't have gs fonts installed. If there are no gs fonts, then gs may not work.
In my convert -list configure, I have
'--with-gs-font-dir=/opt/local/share/ghostscript/fonts/'
When your hosting provider installed GS, they perhaps forgot to install the fonts or did not put that (--with-gs-font-dir=...) into the IM ./configure command to tell GS and IM where the gs fonts are located.
Re: convert PDF to JPG on Unix no results
Hi fmw42,
Thanks much for input, at least gives me a bit more to mull over. I'll see if I have/can get access to the terminal and utilize via run command.
...still up for any other input.
Best,
-PA
Thanks much for input, at least gives me a bit more to mull over. I'll see if I have/can get access to the terminal and utilize via run command.
...still up for any other input.
Best,
-PA
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert PDF to JPG on Unix no results
My best guess is the gs fonts. Check with your hosting provider about that, first.
Re: convert PDF to JPG on Unix no results
Hi fmw42,
Thanks for the advice and did as suggested with running the convert test on SSH. (as before, works fine on our local test)
The command and result..
Command entered:
$ convert Skeleton.pdf Skeletonjpg1.jpg
Result:
CRIT: rangecheck in .setuserparams
Operand stack:
convert: Postscript delegate failed `Skeleton.pdf': @ error/pdf.c/ReadPDFImage/645.
convert: missing an image filename `Skeletonjpg1.jpg' @ error/convert.c/ConvertImageCommand/2970.
--nostringval-- --nostringval-- --nostringval--
This has been past to my hosting provider for correction, along with the note about setting the config option of "--with-gs-font-dir". I'll keep this thread updated with results.
-PA
Thanks for the advice and did as suggested with running the convert test on SSH. (as before, works fine on our local test)
The command and result..
Command entered:
$ convert Skeleton.pdf Skeletonjpg1.jpg
Result:
CRIT: rangecheck in .setuserparams
Operand stack:
convert: Postscript delegate failed `Skeleton.pdf': @ error/pdf.c/ReadPDFImage/645.
convert: missing an image filename `Skeletonjpg1.jpg' @ error/convert.c/ConvertImageCommand/2970.
--nostringval-- --nostringval-- --nostringval--
This has been past to my hosting provider for correction, along with the note about setting the config option of "--with-gs-font-dir". I'll keep this thread updated with results.
-PA
Re: convert PDF to JPG on Unix no results - resolved
The situation with PDF to JPG has been resolved.
My host rebuilt Ghostscript and PDF to JPG worked from the SSH. However, it did not work via PHP.
After further research, it was determined the new GS build was in usr/local/bin, while IM was in usr/bin/. The resolution was to make sure the ImageMagick and newly compiled GhostScript executables were in the same path. Once the host corrected that path assignments, the PHP script PDF to JPG worked.
Fortunately the host is one that is very easy to work with and followed suggestions for troubleshooting and resolution. That, in addition to the guidance from the forum (fmw42).
Everything works "as advertised" now.
Best regards,
-PA
My host rebuilt Ghostscript and PDF to JPG worked from the SSH. However, it did not work via PHP.
After further research, it was determined the new GS build was in usr/local/bin, while IM was in usr/bin/. The resolution was to make sure the ImageMagick and newly compiled GhostScript executables were in the same path. Once the host corrected that path assignments, the PHP script PDF to JPG worked.
Fortunately the host is one that is very easy to work with and followed suggestions for troubleshooting and resolution. That, in addition to the guidance from the forum (fmw42).
Everything works "as advertised" now.
Best regards,
-PA
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert PDF to JPG on Unix no results
Glad to hear all is straightened out.