Skip to content

Instantly share code, notes, and snippets.

@seb-jones
Last active September 1, 2019 09:18
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 seb-jones/2bba5c1bfb7ff224a9ca8e58a8e4dcab to your computer and use it in GitHub Desktop.
Save seb-jones/2bba5c1bfb7ff224a9ca8e58a8e4dcab to your computer and use it in GitHub Desktop.
Takes the results of Pokemon Fusion Scraper and prepares them as frames for video.
#!/bin/bash
#
# Pokemon Fusion Frame Generator
#
# Takes the output of pokemon-fusion-scraper.sh (https://gist.github.com/seb-jones/f5c25453f69ec0bad53d35a733694d8e)
# and converts them into frames for a video.
#
# Requires Image Magick and the Noto Sans font
LEFT_CAPTION_FONT="Noto-Sans-Display-Regular"
RIGHT_CAPTION_FONT="Noto-Sans-Display-Thin"
BACKGROUND_FILE="./background.png"
TEMP_FILE="/tmp/pffg.png"
FILENAMES=$(find ./images | sort -n -t '-' -k 4 -k 5 | grep -vE "^\./images$")
I=1
echo "$FILENAMES" | while read SOURCE_FILE
do
BASENAME=$(echo "$SOURCE_FILE" | sed -e 's/\.png$//' -e 's!\./images/!!')
FUSED_NAME=$(echo "$BASENAME" | cut -d '-' -f 1,1)
NAME1=$(echo "$BASENAME" | cut -d '-' -f 2,2)
NAME2=$(echo "$BASENAME" | cut -d '-' -f 3,3)
LEFT_CAPTION="$FUSED_NAME"
RIGHT_CAPTION="$NAME1 + $NAME2"
convert -resize 200% $SOURCE_FILE $TEMP_FILE
convert -gravity Center -composite $BACKGROUND_FILE $TEMP_FILE $TEMP_FILE
convert -gravity NorthWest -pointsize 72 -font $LEFT_CAPTION_FONT -draw "text 75, 50 '$LEFT_CAPTION' " $TEMP_FILE $TEMP_FILE
convert -gravity NorthEast -pointsize 72 -font $RIGHT_CAPTION_FONT -draw "text 75, 50 '$RIGHT_CAPTION' " $TEMP_FILE $TEMP_FILE
OUTPUT_FILENAME=$(printf "%05i" $I)
OUTPUT_FILENAME="./frames/$OUTPUT_FILENAME.png"
cp "$TEMP_FILE" "$OUTPUT_FILENAME"
echo "$SOURCE_FILE - $OUTPUT_FILENAME"
((I++))
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment