emoji/emoji-convert.sh

42 lines
1.1 KiB
Bash
Raw Normal View History

2022-11-16 03:56:07 +00:00
#!/bin/bash
2022-11-14 00:12:44 +00:00
LENGTH=128
MARGIN=1
WIDTH=126
HEIGHT=84
2022-11-14 00:12:44 +00:00
TEMP=`mktemp -d -p ""`
2022-11-15 06:20:18 +00:00
# pride flags
for svg_path in src/pride/pride-*.svg; do
svg=${svg_path#"src/pride/"}
2022-11-14 00:12:44 +00:00
# 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} \
./dist/pride/${svg%.svg}.png
2022-11-15 06:20:18 +00:00
echo ${svg%.svg} created
done
2022-11-14 00:12:44 +00:00
rm -rf $TEMP
# fix and remove metadata
exiftool -all= -overwrite_original ./dist/pride/*