Created
December 8, 2011 02:17
-
-
Save tdtds/1445789 to your computer and use it in GitHub Desktop.
自炊PDFをKindle向け16階調グレースケールにしてサイズを小さくする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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