blob: 160212b7c673c5b373aa57a9934a9092160d2fb7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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"
}
"$@"
|