Skip to content

Instantly share code, notes, and snippets.

@tdtds tdtds/pdfcompress
Created Dec 8, 2011

Embed
What would you like to do?
自炊PDFをKindle向け16階調グレースケールにしてサイズを小さくする
#!/bin/sh
src=`basename "$1" .pdf`
mkdir tmp
pdftk "${src}.pdf" dump_data output meta.txt
pdfimages "${src}.pdf" "tmp/${src}"
cd tmp
for f in *.ppm; do
tmp=`basename "$f" .ppm`
convert "${tmp}.ppm" -depth 4 -type Grayscale "${tmp}.png"
sam2p -j:quiet "${tmp}.png" "${tmp}.pdf"
rm "${tmp}.ppm" "${tmp}.png"
done
cd ..
pdftk tmp/*.pdf cat output tmp.pdf
pdftk tmp.pdf update_info meta.txt output "${src}.out.pdf"
rm -rf tmp.pdf tmp meta.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.