~ubuntu-branches/debian/sid/freeciv/sid

« back to all changes in this revision

Viewing changes to data/flags/convert_png

  • Committer: Package Import Robot
  • Author(s): Clint Adams, Karl Goetz, Clint Adams
  • Date: 2011-08-28 22:40:00 UTC
  • mfrom: (1.2.19 upstream)
  • Revision ID: package-import@ubuntu.com-20110828224000-j2r1erewlem25dox
Tags: 2.3.0-1
[ Karl Goetz ]
* New upstream version.
* Fix themes_sdl_use_system_fonts.diff to apply cleanly on 2.3.0
* Massage work_around_unity_induced_breakage.diff to get it
  applying to the new codebase (The patch assumes commits made
  after 2.3.0 was tagged upstream).

[ Clint Adams ]
* Fudge build system to think there is no libtool mismatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
#SODIPODI="sodipodi"
7
7
RENDERER="inkscape"
8
8
 
9
 
# Target width: 29 for trident/isotrident (height is then calculated
 
9
# Target width: 29px is regular, 44px is large (height is then calculated
10
10
# automatically).
11
11
TARGET_WIDTH=29
 
12
TARGET_WIDTH_LARGE=44
12
13
 
13
14
SHIELD_WIDTH=14
14
15
SHIELD_HEIGHT=14
 
16
SHIELD_WIDTH_LARGE=19
 
17
SHIELD_HEIGHT_LARGE=19
15
18
 
16
19
which $RENDERER >/dev/null \
17
20
  || (echo "You need $RENDERER to render the SVG files.")
19
22
  || (echo "You need ImageMagick to manipulate the images."; err=yes)
20
23
 
21
24
for file0 in $files; do
22
 
  filebase=`echo $file0 | sed s/.svg$//i`
 
25
  # Generate the regular images
 
26
  filebase=`echo $file0 | sed 's/.[Ss][Vv][Gg]$//'`
23
27
 
24
28
  file1="$filebase-1.png"
25
29
  file2="$filebase-2.png"
52
56
  WIDTH=$(($SHIELD_WIDTH-2))
53
57
  HEIGHT=$(($SHIELD_HEIGHT-2))
54
58
 
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) }')
 
64
  Y0=0
 
65
  Y1=$(awk -v drawing_height=${DRAWING_HEIGHT} 'BEGIN { print int(drawing_height + 0.5) }')
 
66
  AREA=$X0":"$Y0":"$X1":"$Y1
 
67
 
 
68
  $RENDERER -f $file0 -w $WIDTH -h $HEIGHT -e $file1 -a=$AREA > /dev/null
56
69
 
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
60
73
 
61
74
  rm -f $file1 $file2 $file3 "$filebase-4-fs8.png"
 
75
 
 
76
  # Generate the large images
 
77
  filebase=`echo $file0 | sed 's/.[Ss][Vv][Gg]$//'`
 
78
 
 
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"
 
84
 
 
85
  # This is actually necessary for rendering
 
86
  rm -f $file1 $file2 $file3 $file4
 
87
 
 
88
  $RENDERER -f "$file0" -w $(($TARGET_WIDTH_LARGE - 2)) -e "$file1" >/dev/null
 
89
 
 
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//"`
 
94
 
 
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
 
99
 
 
100
  rm -f $file1 $file2 $file3 "$filebase-4-fs8.png"
 
101
 
 
102
  file1="$filebase-1.png"
 
103
  file2="$filebase-2.png"
 
104
  file3="$filebase-3.png"
 
105
  file4="$filebase-shield-large.png"
 
106
 
 
107
  WIDTH=$(($SHIELD_WIDTH_LARGE-2))
 
108
  HEIGHT=$(($SHIELD_HEIGHT_LARGE-2))
 
109
 
 
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) }')
 
115
  Y0=0
 
116
  Y1=$(awk -v drawing_height=${DRAWING_HEIGHT} 'BEGIN { print int(drawing_height + 0.5) }')
 
117
  AREA=$X0":"$Y0":"$X1":"$Y1
 
118
 
 
119
  $RENDERER -f $file0 -w $WIDTH -h $HEIGHT -e $file1 -a=$AREA > /dev/null
 
120
 
 
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
 
124
 
 
125
  rm -f $file1 $file2 $file3 "$filebase-4-fs8.png"
62
126
done