I\'m trying to use the command line program convert to take a PDF into an image (JPEG or PNG). Here is one of the PDFs that I\'m trying to convert.
I want the progr
Please take note before down voting, this solution is for Gimp using a graphical interface, and not for ImageMagick using a command line, but it worked perfectly fine for me as an alternative, and that is why I found it needful to share here.
Follow these simple steps to extract images in any format from PDF documents
That's all.
I hope this helps
I have found it both faster and more stable when batch-processing large PDFs into PNGs and JPGs to use the underlying gs
(aka Ghostscript) command that convert
uses.
You can see the command in the output of convert -verbose
and there are a few more tweaks possible there (YMMV) that are difficult / impossible to access directly via convert
.
However, it would be harder to do your trimming and sharpening using gs
, so, as I said, YMMV!
Use this commandline:
convert -geometry 3600x3600 -density 300x300 -quality 100 TEAM\ 4.pdf team4.png
This should correctly convert the file as you've asked for.
Personally I like this.
convert -density 300 -trim test.pdf -quality 100 test.jpg
It's a little over twice the file size, but it looks better to me.
-density 300
sets the dpi that the PDF is rendered at.
-trim
removes any edge pixels that are the same color as the corner pixels.
-quality 100
sets the JPEG compression quality to the highest quality.
Things like -sharpen
don't work well with text because they undo things your font rendering system did to make it more legible.
If you actually want it blown up use resize here and possibly a larger dpi value of something like targetDPI * scalingFactor
That will render the PDF at the resolution/size you intend.
Descriptions of the parameters on imagemagick.org are here
It also gives you good results:
exec("convert -geometry 1600x1600 -density 200x200 -quality 100 test.pdf test_image.jpg");
Linux user here: I tried the convert
command-line utility (for PDF to PNG) and I was not happy with the results. I found this to be easier, with a better result:
pdftk file.pdf cat 3 output page3.pdf
GIMP
Resolution
from 100
to 300
or 600 pixel/in
GIMP
export as PNG (change file extension to .png)Edit:
Added picture, as requested in the Comments
. Convert command used:
convert -density 300 -trim struct2vec.pdf -quality 100 struct2vec.png
GIMP
: imported at 300 dpi (px/in); exported as PNG compression level 3.
I have not used GIMP on the command line (re: my comment, below).