Last active
September 3, 2022 03:45
-
-
Save kartikynwa/e6304977870800128326f29e3649ce15 to your computer and use it in GitHub Desktop.
cbz scripts
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
#!/usr/bin/env bash | |
# Convert a cbr file to cbz because rar is proprietary | |
set -e | |
tmpdir=$(mktemp -d) | |
cleanup() { | |
rm -rf "$tmpdir" || true | |
} | |
trap cleanup ERR | |
if [ -z "$1" ]; then | |
echo "USAGE: convert RARFILE" | |
exit 1 | |
fi | |
name=$(basename "$1" .rar) | |
unrar x "$1" "$tmpdir" | |
new_file="$(pwd)/$name.zip" | |
cd "$tmpdir" | |
zip -r "$new_file" * | |
cd - | |
cleanup | |
# I hope you have a wonderful day :) | |
# - Kartik |
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
#!/usr/bin/env bash | |
# Shrink a CBZ file so that all images are <=2000px in height | |
# Requires: 7z, fd, GraphicsMagick | |
set -e | |
tmpdir=$(mktemp -d) | |
cleanup() { | |
rm -rf "$tmpdir" || true | |
} | |
trap cleanup ERR | |
if [ -z "$1" ]; then | |
echo "USAGE: mango CBZFILE" | |
exit 1 | |
fi | |
name=$(basename "$1") | |
7z x "$1" -o"$tmpdir" | |
fd . "$tmpdir" -epng -ejpg -ejpeg -ewebp \ | |
-x gm mogrify -verbose -resize x2000\> "{}" | |
new_file="$(pwd)/shrunk_$name" | |
cd "$tmpdir" | |
7z a "$new_file" * -tzip | |
cd - | |
cleanup | |
# I hope you have a wonderful day :) | |
# - Kartik |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment