#!/bin/bash

# A script to create a square flyer using ImageMagick
filename="flyer_${1}.png"
filenameresized="resized_${filename}"
filenamesquare="square_${filename}"
filenamejpg="square_flyer_${1}.jpg"
filenamewebp="square_flyer_${1}.webp"
echo "Going into directory $1"
cd $1
cp ../flyer_inkscape_background.png .
convert -background green -gravity center flyer_inkscape_background.png -extent 1200x1200 background.png
convert -resize 1000x1000 $filename $filenameresized
convert -composite -gravity center background.png $filenameresized $filenamesquare
convert $filenamesquare $filenamejpg
convert $filenamesquare $filenamewebp
# cleanup
rm $filenameresized
rm background.png
rm flyer_inkscape_background.png
echo "Created $filenamesquare , $filenamejpg and $filenamewebp "
