Skip to content

Instantly share code, notes, and snippets.

@igungor
Created May 3, 2012 22:02
Show Gist options
  • Save igungor/2589858 to your computer and use it in GitHub Desktop.
Save igungor/2589858 to your computer and use it in GitHub Desktop.
Manga converter for Kindle screen
#!/bin/bash
if [ ! -x $(which gm) ]
then
echo "GraphicsMagick is required."
exit 1
fi
TMPDIR=$(mktemp -d)
for file in *
do
resolution=($(gm identify -format "%w %h" "$file" 2>/dev/null))
if [ $? -eq 0 ] # Make sure if it's a valid image.
then
cp "$file" $TMPDIR/
gm convert -rotate "-90>" "$TMPDIR/$file" "$TMPDIR/$file"
gm mogrify -depth 4 -colorspace gray -type palette -geometry x800 "$TMPDIR/$file"
fi
done
zip $(basename $(pwd)).cbz $TMPDIR/* > /dev/null
rm -r $TMPDIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment