52
56
WIDTH=$(($SHIELD_WIDTH-2))
53
57
HEIGHT=$(($SHIELD_HEIGHT-2))
55
$RENDERER -f $file0 -w $WIDTH -h $HEIGHT -e $file1 > /dev/null
59
# The following assumes that the drawing has the same dimensions as the page
60
DRAWING_WIDTH=$($RENDERER -f $file0 -W)
61
DRAWING_HEIGHT=$($RENDERER -f $file0 -H)
62
X0=$(awk -v drawing_width=${DRAWING_WIDTH} 'BEGIN { print int((drawing_width / 6) + 0.5) }')
63
X1=$(awk -v x0=${X0} 'BEGIN{ print int((x0 * 5) + 0.5) }')
65
Y1=$(awk -v drawing_height=${DRAWING_HEIGHT} 'BEGIN { print int(drawing_height + 0.5) }')
66
AREA=$X0":"$Y0":"$X1":"$Y1
68
$RENDERER -f $file0 -w $WIDTH -h $HEIGHT -e $file1 -a=$AREA > /dev/null
57
70
composite -gravity center -compose src-over $file1 mask.png $file2
58
71
composite -gravity center -compose src-over mask.png $file2 $file3
59
72
convert -transparent magenta $file3 $file4
61
74
rm -f $file1 $file2 $file3 "$filebase-4-fs8.png"
76
# Generate the large images
77
filebase=`echo $file0 | sed 's/.[Ss][Vv][Gg]$//'`
79
file1="$filebase-1.png"
80
file2="$filebase-2.png"
81
file3="$filebase-3.png"
82
file4="$filebase-large.png"
83
echo "Converting $file0 to $file4"
85
# This is actually necessary for rendering
86
rm -f $file1 $file2 $file3 $file4
88
$RENDERER -f "$file0" -w $(($TARGET_WIDTH_LARGE - 2)) -e "$file1" >/dev/null
90
# Ugly way to determine width and height. There must be a better way!
91
SIZE=`identify "$file1" | sed "s/^.*PNG //" | sed "s/ .*\$//"`
92
WIDTH=`echo $SIZE | sed "s/x.*\$//"`
93
HEIGHT=`echo $SIZE | sed "s/^.*x//"`
95
# This complicated code puts a 1-pixel black border around the image.
96
convert -resize $((2*$WIDTH))x$((2*$HEIGHT)) -fill black -draw "rectangle 0,0 $((2*$WIDTH)),$((2*$HEIGHT))" $file1 $file2
97
convert -crop $((2+$WIDTH))x$((2+$HEIGHT))+0x0 $file2 $file3
98
composite -gravity center -compose src-over $file1 $file3 $file4
100
rm -f $file1 $file2 $file3 "$filebase-4-fs8.png"
102
file1="$filebase-1.png"
103
file2="$filebase-2.png"
104
file3="$filebase-3.png"
105
file4="$filebase-shield-large.png"
107
WIDTH=$(($SHIELD_WIDTH_LARGE-2))
108
HEIGHT=$(($SHIELD_HEIGHT_LARGE-2))
110
# The following assumes that the drawing has the same dimensions as the page
111
DRAWING_WIDTH=$($RENDERER -f $file0 -W)
112
DRAWING_HEIGHT=$($RENDERER -f $file0 -H)
113
X0=$(awk -v drawing_width=${DRAWING_WIDTH} 'BEGIN { print int((drawing_width / 6) + 0.5) }')
114
X1=$(awk -v x0=${X0} 'BEGIN{ print int((x0 * 5) + 0.5) }')
116
Y1=$(awk -v drawing_height=${DRAWING_HEIGHT} 'BEGIN { print int(drawing_height + 0.5) }')
117
AREA=$X0":"$Y0":"$X1":"$Y1
119
$RENDERER -f $file0 -w $WIDTH -h $HEIGHT -e $file1 -a=$AREA > /dev/null
121
composite -gravity center -compose src-over $file1 mask-large.png $file2
122
composite -gravity center -compose src-over mask-large.png $file2 $file3
123
convert -transparent magenta $file3 $file4
125
rm -f $file1 $file2 $file3 "$filebase-4-fs8.png"