Skip to content

Instantly share code, notes, and snippets.

@altbdoor
Created October 30, 2016 15:22
Show Gist options
  • Save altbdoor/3166d891ed45d68d5a93118ce4805f9a to your computer and use it in GitHub Desktop.
Save altbdoor/3166d891ed45d68d5a93118ce4805f9a to your computer and use it in GitHub Desktop.
Bash script to finalize 4koma
#!/bin/bash
CURRENT_DIR=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )
cd "$CURRENT_DIR"
hash gm 2>/dev/null || {
echo "Please install GraphicsMagick (Q8 win32 dll) first."
echo "Go get it at https://sourceforge.net/projects/graphicsmagick/files/graphicsmagick-binaries/"
exit 1
}
pngout_path=""
if hash pngout 2>/dev/null; then
pngout_path="pngout"
else
if [[ -f ./pngout.exe ]]; then
pngout_path="./pngout.exe"
else
echo "Please install pngout first."
echo "Go get it at http://advsys.net/ken/util/pngout.exe"
exit 1
fi
fi
font_name="animeace2_reg"
if [[ ! -f "/c/Windows/Fonts/$font_name.ttf" ]]; then
echo "Please install Anime Ace 2 font first."
echo "Go get it at http://www.blambot.com/_fonts/animeace2bb_tt.zip"
exit 1
fi
koma_file="$1"
if [[ -z "$koma_file" || ! -f "./$koma_file" ]]; then
echo "Please provide 4koma input filename."
exit 1
fi
koma_text="$2"
if [[ -z "$koma_text" ]]; then
echo "Please provide 4koma title."
exit 1
fi
echo "GraphicsMagick doing magic..."
gm convert "$koma_file" -quality 100 -filter Sinc -bordercolor black -border 4x0 -resize x800 -bordercolor white -border 0x40 -gravity South -chop 0x40 -font "C:\\Windows\\Fonts\\$font_name.ttf" -fill black -pointsize 16 -gravity North -draw "text 0,25 \"$koma_text\"" output.png
echo "pngout doing magic..."
"$pngout_path" output.png
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment