Issue converting PDF to JPG
Issue converting PDF to JPG
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!
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
Supply some more info:
Imagemagick version
How are you working - command line, php etc.
Example input image if possible.
Example of output if possible.
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
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.
Currently working command line but the intention is to exec it in a PHP script.
PM'ed input and output.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Issue converting PDF to JPG
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
convert -colorspace rgb image.pdf image.jpg
Re: Issue converting PDF to JPG
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.
Strange thing is that the convert creates an image file of what looks to be correct filesize.
Re: Issue converting PDF to JPG
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Issue converting PDF to JPG
can you post your pdf?
Re: Issue converting PDF to JPG
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
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
404 Error with that link
Re: Issue converting PDF to JPG
Should be okay now, otherwise is there a way of attaching the doc to the board?
Re: Issue converting PDF to JPG
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.
Back in a 1/2hr or so - Dinner ready.
The link works now.
Re: Issue converting PDF to JPG
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 ?
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">
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Issue converting PDF to JPG
squiddon wrote:http://www.nicklog.spindogs5.co.uk/test.pdf
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