88 lines
2.7 KiB
Bash
Executable File
88 lines
2.7 KiB
Bash
Executable File
LENGTH=128
|
|
MARGIN=1
|
|
WIDTH=126
|
|
HEIGHT=84 # flags
|
|
#ROUND=10
|
|
|
|
TEMP=`mktemp -d -p ""`
|
|
|
|
# pride flags
|
|
for svg_path in pride/svg/*.svg; do
|
|
svg=${svg_path#"pride/svg/"}
|
|
# resize
|
|
convert ${svg_path} \
|
|
-resize ${WIDTH}x${HEIGHT} \
|
|
$TEMP/resized-${svg%.svg}.png
|
|
# round borders
|
|
magick $TEMP/resized-${svg%.svg}.png \
|
|
\( +clone -alpha extract \
|
|
-draw 'fill black polygon 0,0 0,10 10,0 fill white circle 10,10 10,0' \
|
|
\( +clone -flip \) -compose Multiply -composite \
|
|
\( +clone -flop \) -compose Multiply -composite \
|
|
\) -alpha off -compose CopyOpacity -composite $TEMP/rounded-${svg%.svg}.png
|
|
# add margin
|
|
convert $TEMP/rounded-${svg%.svg}.png \
|
|
-bordercolor transparent \
|
|
-border ${MARGIN} \
|
|
$TEMP/margin-${svg%.svg}.png
|
|
# make square
|
|
convert -background transparent \
|
|
-gravity center \
|
|
$TEMP/margin-${svg%.svg}.png \
|
|
-extent ${LENGTH}x${LENGTH} \
|
|
./pride/png/${svg%.svg}.png
|
|
echo ${svg%.svg} created
|
|
done
|
|
|
|
# branding
|
|
for svg_path in branding/svg/*.svg; do
|
|
svg=${svg_path#"branding/svg/"}
|
|
if [[ $svg == "treehouse-icon-wordmark.svg" ]] || [[ $svg == "treehouse-logo-full.svg" ]]; then
|
|
# resize
|
|
# create white background
|
|
convert ${svg_path} \
|
|
-resize ${WIDTH}x${WIDTH} \
|
|
$TEMP/resized-${svg%.svg}.png
|
|
else
|
|
# resize
|
|
# creates clear background
|
|
convert -background none \
|
|
${svg_path} \
|
|
-resize ${WIDTH}x${WIDTH} \
|
|
$TEMP/resized-${svg%.svg}.png
|
|
fi
|
|
if [[ $svg == "treehouse-icon-wordmark.svg" ]] \
|
|
|| [[ $svg == "treehouse-logo-full.svg" ]]; then
|
|
# round borders
|
|
magick $TEMP/resized-${svg%.svg}.png \
|
|
\( +clone -alpha extract \
|
|
-draw \
|
|
'fill black polygon 0,0 0,10 10,0 fill white circle 10,10 10,0' \
|
|
\( +clone -flip \) -compose Multiply -composite \
|
|
\( +clone -flop \) -compose Multiply -composite \
|
|
\) -alpha off -compose CopyOpacity -composite \
|
|
$TEMP/rounded-${svg%.svg}.png
|
|
else
|
|
# already rounded
|
|
cp $TEMP/resized-${svg%.svg}.png $TEMP/rounded-${svg%.svg}.png
|
|
fi
|
|
# add margin
|
|
convert $TEMP/rounded-${svg%.svg}.png \
|
|
-bordercolor transparent \
|
|
-border ${MARGIN} \
|
|
$TEMP/margin-${svg%.svg}.png
|
|
# make square
|
|
convert -background transparent \
|
|
-gravity center \
|
|
$TEMP/margin-${svg%.svg}.png \
|
|
-extent ${LENGTH}x${LENGTH} \
|
|
./branding/png/${svg%.svg}.png
|
|
echo ${svg%.svg} created
|
|
done
|
|
|
|
rm -rf $TEMP
|
|
|
|
# fix and remove metadata
|
|
exiftool -all= -overwrite_original ./pride/png/*
|
|
exiftool -all= -overwrite_original ./branding/png/*
|