Page 1 of 2
Issue converting PDF to JPG
Posted: 2009-05-20T03:28:40-07:00
by squiddon
Hi guys,
I'm a bit of a n00b to ImageMagick and I'm having trouble converting a PDF document to a JPG. The conversion seems to work on initial inspection but the output file is an unreadable JPG file. I'm running ImageMagick and GhostScript on a linux server. Has anyone had a similar issue?
Cheers in advance!
Re: Issue converting PDF to JPG
Posted: 2009-05-20T04:42:58-07:00
by Bonzo
Supply some more info:
Imagemagick version
How are you working - command line, php etc.
Example input image if possible.
Example of output if possible.
Re: Issue converting PDF to JPG
Posted: 2009-05-20T06:09:47-07:00
by squiddon
ImageMagick-6.5.2-7
Currently working command line but the intention is to exec it in a PHP script.
PM'ed input and output.
Re: Issue converting PDF to JPG
Posted: 2009-05-20T09:01:41-07:00
by fmw42
I have had that problem I believe. I think it is due to the pdf being cmyk format and my ghostscript cannot handle that. To get around that, if that is the problem, try
convert -colorspace rgb image.pdf image.jpg
Re: Issue converting PDF to JPG
Posted: 2009-05-20T09:28:58-07:00
by squiddon
Thanks for the suggestion, I had a go but to no avail. I've tried to change the document in case it is also a document permissions issue (I had to try!), but again, no joy.
Strange thing is that the convert creates an image file of what looks to be correct filesize.
Re: Issue converting PDF to JPG
Posted: 2009-05-20T09:29:27-07:00
by Bonzo
I think there is a problem with your input pdf; I have tried different things including Freds suggestion but get this error everytime using php. I didn't even get the output you did !
Array
(
[0] => convert: `%s': %s "gswin32c.exe" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVICE=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" "-sOutputFile=C:/Users/Anthony/AppData/Local/Temp/magick-wlRI0-Rd" "-fC:/Users/Anthony/AppData/Local/Temp/magick-dkn1da4r" "-fC:/Users/Anthony/AppData/Local/Temp/magick-g9EoQYAV" @ utility.c/SystemCommand/1843.
[1] => convert: Postscript delegate failed `test.pdf': No such file or directory @ pdf.c/ReadPDFImage/612.
[2] => convert: missing an image filename `image.jpg' @ convert.c/ConvertImageCommand/2775.
)
1
Re: Issue converting PDF to JPG
Posted: 2009-05-20T09:29:44-07:00
by fmw42
can you post your pdf?
Re: Issue converting PDF to JPG
Posted: 2009-05-20T09:32:58-07:00
by squiddon
I'll find one that I'm generating using FPDF, which will ultimately be my input, bear with me a second...
Re: Issue converting PDF to JPG
Posted: 2009-05-20T09:33:11-07:00
by Bonzo
I have just created a pdf using Microsoft office 2007 and I get the same results. How did you create your pdf ?
Re: Issue converting PDF to JPG
Posted: 2009-05-20T09:43:37-07:00
by squiddon
Re: Issue converting PDF to JPG
Posted: 2009-05-20T09:44:35-07:00
by Bonzo
404 Error with that link
Re: Issue converting PDF to JPG
Posted: 2009-05-20T09:47:19-07:00
by squiddon
Should be okay now, otherwise is there a way of attaching the doc to the board?
Re: Issue converting PDF to JPG
Posted: 2009-05-20T09:53:02-07:00
by Bonzo
WOOPS New PC and I do not think I have installed Ghost script
Back in a 1/2hr or so - Dinner ready.
The link works now.
Re: Issue converting PDF to JPG
Posted: 2009-05-20T10:29:23-07:00
by Bonzo
Very sorry for the false leads - installed Ghostscript now and it all works OK on the posted sample.
IM version 6.5.1
What result do you get for your posted pdf ?
Code: Select all
<?php
exec("convert test.pdf jpg4.jpg");
exec("convert -density 300 test.pdf jpg5.jpg");
?>
<img src="jpg4.jpg">
<img src="jpg5.jpg">
Re: Issue converting PDF to JPG
Posted: 2009-05-20T10:41:16-07:00
by fmw42
This works just fine for me on IM 6.5.2-7 Q16 Mac OSX Tiger with Ghostscript ghostscript-8.61.tar.gz
convert test.pdf test.jpg
convert -list configure
Path: /usr/local/lib/ImageMagick-6.5.2/config/configure.xml
Name Value
-------------------------------------------------------------------------------
CC gcc -std=gnu99
CFLAGS -I/usr/local/include/lqr-1 -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -g -O2 -Wall -W -D_THREAD_SAFE
CONFIGURE ./configure '--enable-delegate-build' '--enable-shared' '--disable-static' '--with-modules' '--with-quantum-depth=16'
'--with-gslib' '--without-wmf' '--enable-libtool-verbose' '--disable-dependency-tracking'
'--with-gs-font-dir=/usr/local/share/ghostscript/fonts/' '--with-lqr'
COPYRIGHT Copyright (C) 1999-2009 ImageMagick Studio LLC
CPPFLAGS -I/usr/local/include/ImageMagick
CXX g++
CXXFLAGS -g -O2 -Wall -W -D_THREAD_SAFE
DEFS -DHAVE_CONFIG_H
DELEGATES bzlib fontconfig freetype gs jpeg jng jp2 lcms lqr openexr png tiff x11 xml zlib