Skip to content

Instantly share code, notes, and snippets.

@sepastian
Created May 4, 2022 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sepastian/31eeaa5a0b938ce407d04de039c77d4b to your computer and use it in GitHub Desktop.
Save sepastian/31eeaa5a0b938ce407d04de039c77d4b to your computer and use it in GitHub Desktop.
Extract PDF images in parallel
# For each page in input.pdf,
# generate image(s) in PNG format
# named output_<PAGE>.png
# where PAGE is a 4-digit zero-padded number.
pdfinfo input.pdf \
| grep Pages \
| awk -F'[: ]*' '{print $2}' \
| xargs seq \
| parallel \
'\
p=$(printf "%04d\n" {}); \
echo page ${p}; \
pdfimages -png -f {} -l {} \
input.pdf \
output_${p}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment