简体   繁体   中英

How to convert a folder of images from .pdf to .png?

I have a folder of pdf files(~ 1600 images). I want to convert all.pdf images into.png images. How can I do it?

I tried :

find. -maxdepth 1 -type f -name '*.pdf' -exec pdftoppm -r 300 -png {} {};

But have errors like:

Syntax Error: non-embedded font using identity encoding: Arial
Syntax Error: non-embedded font using identity encoding: Arial,Bold
Syntax Error: Can't get Fields array<0a>
Syntax Warning: Mismatch between font type and embedded font file
Syntax Error: Expected the optional content group list, but wasn't able to find it, or it isn't an Array

Is there any other solution for conversion?

You can create PNG versions of all PDFs in the current directory with ImageMagick like this:

magick mogrify -density 300 -format PNG *.pdf

If you want the output files in a sub-directory called OUTPUT , use:

mkdir OUTPUT
magick mogrify -path OUTPUT -density 300 -format PNG *.pdf

As you have 1600 PDFs, you might consider using GNU Parallel to do them in parallel for you:

parallel magick {} -density 300 {.}.png ::: *.pdf

You can use ImageMagick to convert a png to a pdf

convert input.pdf -density 300 -alpha remove output.png        

Here:

  • the -density 300 sets the DPI resolution to 300
  • the -alpha remove makes it so the PDF file is not see through (an issue that can often, but not always happen)

You can use this to do something like this

find . -maxdepth 1 -type f -name '*.pdf' -exec convert {} -density 300 -alpha remove {}.png \;  

Notice that the output filename will be somefile.pdf.png this way thou.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM