Convert PDF to image with high resolution

前端 未结 18 1899
故里飘歌
故里飘歌 2020-11-28 00:13

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

相关标签:
18条回答
  • 2020-11-28 00:29

    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

    1. Download GIMP Image Manipulation Program
    2. Open the Program after installation
    3. Open the PDF document that you want to extract Images
    4. Select only the pages of the PDF document that you would want to extract images from. N/B: If you need only the cover images, select only the first page.
    5. Click open after selecting the pages that you want to extract images from
    6. Click on File menu when GIMP when the pages open
    7. Select Export as in the File menu
    8. Select your preferred file type by extension (say png) below the dialog box that pops up.
    9. Click on Export to export your image to your desired location.
    10. You can then check your file explorer for the exported image.

    That's all.

    I hope this helps

    0 讨论(0)
  • 2020-11-28 00:32

    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!

    0 讨论(0)
  • 2020-11-28 00:34

    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.

    0 讨论(0)
  • 2020-11-28 00:38

    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

    0 讨论(0)
  • 2020-11-28 00:38

    It also gives you good results:

    exec("convert -geometry 1600x1600 -density 200x200 -quality 100 test.pdf test_image.jpg");
    
    0 讨论(0)
  • 2020-11-28 00:38

    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:

    • extract the pdf page(s) with pdftk
      • e.g.: pdftk file.pdf cat 3 output page3.pdf
    • open (import) that pdf with GIMP
      • important: change the import Resolution from 100 to 300 or 600 pixel/in
    • 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).

    0 讨论(0)
提交回复
热议问题