- Use batch for-loops
- Extract images with pdfimages (from xpdf tools)
- Convert extracted images with imagemagick
Code: Select all
for /r %%i in (*.pdf) do pdfimages "%%i" "%%i"
for /r %%i in (*.pgm) do magick "%%i" "%%i.png"
for /r %%i in (*.ppm) do magick "%%i" "%%i.png"
Code: Select all
for /r %%i in (*.pgm) do del "%%i"
for /r %%i in (*.ppm) do del "%%i"
for /r %%i in (*.pdf) do del "%%i"
They do have long xx.pdf-0000.ppm.png filenames now, but the important information is still there, and they're still in the right locations.
Original message was:
ImageMagick 7.0.8-33
I have several directories of pdfs, each consisting of a single image. In order to use them as the images they are, I'm trying to convert them to pngs. But since some are organized by filename and some by folder location:
- They have to keep their current name (but with .png instead of .pdf)
- They have to stay in the same directory
Here are some of the things I can recall trying so far:
Code: Select all
magick mogrify -density 300 *.pdf -format png
Code: Select all
magick convert -density 300 *.pdf -quality 100 *.png
Trying to run this one again (to confirm this was the command I'm remembering) now only gives me "WriteBlob Failed `*-##.png' @ error/png.c/MagickPNGErrorHandler/1714." So maybe I had used a different command? Then, why did it work that one time? I'm so easily confused.
I feel like there must be some easy indicator to tell ImageMagick that I want the output file to match each input file, but I can't find it.