Page 1 of 1
Convert large pdf file to image
Posted: 2014-02-12T23:25:24-07:00
by kasthuri
I tried to convert the pdf file sized 10MB to jpg format using Imagemagick convert function with -geometry 300, but it turn up to be black image. Can anyone help me with this issue?
Re: Convert large pdf file to image
Posted: 2014-02-13T15:45:19-07:00
by fmw42
what was your exact command. what version of IM and what platform. do you have ghostscript delegate installed
what do you get from
convert -version
Re: Convert large pdf file to image
Posted: 2014-02-13T18:20:03-07:00
by kasthuri
Thank you for your response. Imagemagick version that I'm using is ImageMagick-6.8.6-Q16 with windows 8 platform and PHP. I have installed ghostscript g910w32.
The convert command i have used is
$im = new phmagick();
$im->execute("convert -quality 100 -density 300 -geometry 200 drawing_primer.pdf[0] $output");
echo '<pre>';
print_r($im->getLog());
echo '</pre>';
Array
(
[0] => Array
(
[cmd] => convert -quality 100 -density 300 -geometry 200 drawing_primer.pdf[0] convert/drawing_primer.jpg
[return] => 0
[output] => Array
)
)
this was the output but my image looks blank and black.
*** note my pdf file size is 343kb and consist of only one page.
Re: Convert large pdf file to image
Posted: 2014-02-14T13:09:28-07:00
by fmw42
what do you get back from
convert -version
or
convert -list configure
at the line starting wth Delegates.
Does it include gs (ghostscript)?
If it does, please upload your pdf file to some free hosting service such as dropbox (public folder) and put a link here so others can check your image
Re: Convert large pdf file to image
Posted: 2014-02-14T15:10:46-07:00
by snibgo
Is the document black text on a transparent (ie black-transparent) background? If so then putting "-background white" before or after the PDF may cure the problem.
Re: Convert large pdf file to image
Posted: 2014-02-16T20:44:08-07:00
by kasthuri
Hi,
I have tried -background white but the result was still same.
https://www.dropbox.com/s/4w7m6rudqpcsg ... primer.pdf - this is the original file to be converted
https://www.dropbox.com/s/0wwik94hx2w2um4/drawing1.jpg - this is the output file.
Re: Convert large pdf file to image
Posted: 2014-02-16T23:21:54-07:00
by fmw42
This works just fine for me on IM 6.8.0.5
Code: Select all
convert -density 300 -background white drawing_primer.pdf[0] drawing_primer.jpg
You need to set a white backgorund since jpg does not support transparency
$im = new phmagick();
what is phmagick? do you mean Imagick? or are you just trying to use PHP exec() command. If the latter, I do not think your syntax is correct, but I am not a PHP expert.
Try either
Code: Select all
<?php
exec("convert -density 300 -background white drawing_primer.pdf[0] drawing_primer.jpg",$out,$returnval);
{echo "$out<br>";}
echo "<br>";
?>
or
Code: Select all
<?php
exec("fullpath2/convert -density 300 -background white drawing_primer.pdf[0] drawing_primer.jpg",$out,$returnval);
{echo "$out<br>";}
echo "<br>";
?>
The only other issue I can think of is that your ps delegate needs to be using sDEVICE=pngalpha since you have a pdf with transparency.
check your delegates.xml file
<delegate decode="ps:alpha" stealth="True" command=""gsc" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-
sDEVICE=pngalpha" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "-f%s" "-f%s""/>
Re: Convert large pdf file to image
Posted: 2014-02-17T00:41:35-07:00
by kasthuri
thank you very much now it works fine for me. but i just want to ask why if insert -resize or -geometry the output back to as previous.
Re: Convert large pdf file to image
Posted: 2014-02-17T11:06:51-07:00
by fmw42
-geometry is not the right command. If you want to add -resize, then do that after reading the pdf file.
Code: Select all
convert -density 288-background white drawing_primer.pdf[0] -resize 25% drawing_primer.jpg
That will expand the pdf and then resize it back to the original 72 dpi. But you may need a higher output resolution. That is why I just used -density 300 (or -density 288). The output size is controlled by the -density argument. The only reason to resize down again is if you want to match 72 dpi for example, but then the image will be smaller and may not give you adequate resolution for your lines.
Re: Convert large pdf file to image
Posted: 2014-02-17T19:33:49-07:00
by kasthuri
Thank you very much.. now I understand better... really appreciate your help...
Thank you...