diff options
Diffstat (limited to 'misc/flag-icons/files/makeflags.sh')
-rw-r--r-- | misc/flag-icons/files/makeflags.sh | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/misc/flag-icons/files/makeflags.sh b/misc/flag-icons/files/makeflags.sh new file mode 100644 index 000000000000..160212b7c673 --- /dev/null +++ b/misc/flag-icons/files/makeflags.sh @@ -0,0 +1,67 @@ +simple() +{ + local comment convert_extra_args destdir height ratio subdir t0 width + + comment=$1; convert_extra_args=$2; destdir=$3; shift 3 + + for subdir in ?x?; do + ratio=${subdir%x*}/${subdir#*x} + for height; do + width=$((height * $ratio)) + mkdir -p "$destdir/${width}x${height}" + echo -n "Generating $comment flags ${width}x${height}... " + t0=$(date +%s) + for flag in $subdir/*.svg; do + convert -resize ${width}x${height} $convert_extra_args \ + "$flag" "$destdir/${width}x${height}/$(basename "$flag" svg)png" + done + echo "finished in $(date -ur $((`date +%s`-t0)) +%M:%S)" + done + done +} + +plain() +{ + simple undecorated -strip "$@" +} + +bordered() +{ + simple black-bordered '-shave 1x1 -bordercolor black -border 1 -strip' "$@" +} + +# https://joeldare.com/rounding-image-corners-with-imagemagick +rounded() +{ + local destdir height mask radius ratio subdir t0 width + + destdir=$1; shift + mask=$(mktemp) + + for subdir in ?x?; do + ratio=${subdir%x*}/${subdir#*x} + for height; do + width=$((height * $ratio)) + radius=$((height / 10)) + + convert -size ${width}x${height} xc:none -draw \ + "roundRectangle 0,0,$((width-1)),$((height-1)),$radius,$radius" \ + -strip "png:$mask" + + mkdir -p "$destdir/${width}x${height}" + + echo -n "Generating rounded corner flags ${width}x${height}... " + t0=$(date +%s) + for flag in $subdir/*.svg; do + convert -resize ${width}x${height} \ + "$flag" -matte "$mask" \ + -compose DstIn -composite -strip \ + "$destdir/${width}x${height}/$(basename "$flag" svg)png" + done + echo "finished in $(date -ur $((`date +%s`-t0)) +%M:%S)" + done + done + rm "$mask" +} + +"$@" |