Converting a multi page pdf to multiple pages using a single command

前端 未结 4 1180
醉梦人生
醉梦人生 2020-12-28 13:44

I want to convert multi page pdfs into single page images efficiently.

I already know how to do this one page at a time with imagemagick. For example,



        
相关标签:
4条回答
  • 2020-12-28 14:02

    When I tried to convert my multi-page pdf, the resulting image files had a gray background despite the pdf having a white background. (@John P commented on it on the accepted answer, but I couldn't get his comment to directly work for me.)

    Here's what worked for me to make the background white:

    convert -authenticate yourpassword -background white -alpha remove -alpha off -density 300 -quality 80 -verbose "Your file.pdf" "Your file.png"

    My pdf had a password hence the authenticate. You can see a summary of the options here:

    -authenticate value decipher image with this password

    -background color background color

    -alpha on, activate, off, deactivate, set, opaque, copy", transparent, extract, background, or shape the alpha channel

    -density geometry horizontal and vertical density of the image

    -quality value JPEG/MIFF/PNG compression level

    -verbose print detailed information about the image

    More detail: https://imagemagick.org/script/convert.php

    And the alpha remove option: http://www.imagemagick.org/Usage/masking/#alpha_remove

    0 讨论(0)
  • 2020-12-28 14:05

    You're missing the quantity of digits. Use:

    convert x.pdf x-%04d.jpg
    

    Where 4 means 4 digits will be show on the page count.

    0 讨论(0)
  • 2020-12-28 14:05

    If you use Graphicsmagick on Debian or ImageMagick on macOS you probably have to add ADJOIN to your command. So it should look like

    convert x.pdf +adjoin x-%04d.jpg
    
    0 讨论(0)
  • 2020-12-28 14:15

    Ran into the same issue. Reinstall Imagemagick to work in Mountain Lion. If you use brew the simply

      $brew unlink imagemagick
      $brew install imagemagick
    
    0 讨论(0)
提交回复
热议问题