Created
May 14, 2013 14:31
-
-
Save hktechn0/5576394 to your computer and use it in GitHub Desktop.
Convert PDF ebook for Kobo Touch
This file contains hidden or 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/bash | |
##### SETTINGS ##### | |
WIDTH=600 | |
HEIGHT=750 | |
OUTDIR="./cbz" | |
OUTFILE="${1}.cbz" | |
#################### | |
if [ $# -lt 1 ]; then | |
echo "no input files." | |
exit | |
fi | |
mkdir ${OUTDIR} | |
i=0 | |
while true; do | |
filename=`printf "%03d" $i` | |
convert \ | |
\( -size ${WIDTH}x${HEIGHT} xc:white \) \ | |
\( \ | |
\( \ | |
-density 300x300 -type GrayScale \ | |
-define pdf:use-trimbox=true $1"[$i]" \ | |
-level 3%,90%,2.0 \ | |
\) \ | |
-fuzz 70% -trim \ | |
-bordercolor '#ffffff' -border 3%x0% \ | |
-density 96x96 -resize x${HEIGHT} \ | |
\) \ | |
-gravity center -composite \ | |
-type GrayScale -quality 90 \ | |
-verbose ${OUTDIR}/${filename}.jpg | |
if [ $? != 0 ]; then | |
break | |
fi | |
i=$[i + 1] | |
done | |
#pdftk ${OUTDIR}/*.pdf cat output out.pdf | |
zip -r $OUTFILE $OUTDIR | |
rm -r $OUTDIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment