Skip to content

Instantly share code, notes, and snippets.

@XORwell
Created March 16, 2014 11:29
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 XORwell/9581860 to your computer and use it in GitHub Desktop.
Save XORwell/9581860 to your computer and use it in GitHub Desktop.
#!bin/bash
# Requirements: imagemagick, ghostscript, pdftk
#############################################
# create pdf for each png
#############################################
for image in *.png; do
filename="${image%%.*}".pdf
convert $image $filename
done
#############################################
# Convert image files (in reversed order) into one PDF and use ghostscript to shrink the filesize
#############################################
convert img_* -reverse output.pdf #for black/white add: -colorspace Gray
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -sOutputFile=output-shrinked.pdf output.pdf
#############################################
# reverse page order
#############################################
pdftk in.pdf cat end-1 output out.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment