Skip to content

Instantly share code, notes, and snippets.

@josh-richardson
Last active October 15, 2018 04:05
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 josh-richardson/6cee672981648c4a6d1e0f274e41248b to your computer and use it in GitHub Desktop.
Save josh-richardson/6cee672981648c4a6d1e0f274e41248b to your computer and use it in GitHub Desktop.
Shoddily made bash script to lossy compress epub files which are too big. Requires jpegoptim and pngquant.
for i in *.epub
do
dir=`basename "$i" .epub`
7z x "$i" -y -o"$dir" &>/dev/null
find "$dir" -name \*.png -exec pngquant --quality=40-50 -f --ext .png {} \;
find "$dir" -name \*.jpg -exec jpegoptim -m60 {} \;
cd "$dir"
zip -9 -r "$dir.small.epub" .
mv "$dir.small.epub" ../
cd -
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment