Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2004:
[Freeciv-Dev] Re: (PR#10734) SVG flags
Home

[Freeciv-Dev] Re: (PR#10734) SVG flags

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#10734) SVG flags
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 28 Oct 2004 11:33:48 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=10734 >

Finally here's an updated convert_png.  This uses pngquant to convert to 
indexed PNGs.

This isn't a very good solution since pngquant isn't included in any 
distributions and isn't easy to compile.  Also indexed PNGs can only 
support up to 256 colors so there's a limited amount we can do with them.

In the long run it would probably be better to use gimp scripting rather 
than sodipodi + imagemagick + pngquant.

jason


#!/bin/sh

files="$@"

# Renderer: inkscape or sodipodi.  Inkscape seems slightly better.
#SODIPODI="sodipodi"
RENDERER="inkscape"

# Target width: 28 for trident/isotrident (height is then calculated
# automatically).
TARGET_WIDTH=28

for file0 in $files; do
  filebase=`echo $file0 | sed s/.svg$//i`

  file1="$filebase-1.png"
  file2="$filebase-2.png"
  file3="$filebase-3.png"
  file4="$filebase-4.png"
  file5="$filebase.png"
  echo "Converting $file0 to $file5"

  # This is actually necessary for rendering
  rm -f $file1 $file2 $file3 $file4 $file5

  $RENDERER -f "$file0" -w $(($TARGET_WIDTH - 2)) -e "$file1" >/dev/null

  # Ugly way to determine width and height.  There must be a better way!
  SIZE=`identify "$file1" | sed "s/^.*PNG //" | sed "s/ .*\$//"`
  WIDTH=`echo $SIZE | sed "s/x.*\$//"`
  HEIGHT=`echo $SIZE | sed "s/^.*x//"`

  convert -resize $((2*$WIDTH))x$((2*$HEIGHT)) -fill black -draw "rectangle 0,0 
$((2*$WIDTH)),$((2*$HEIGHT))" $file1 $file2

  convert -crop $((2+$WIDTH))x$((2+$HEIGHT))+0x0 $file2 $file3

#  convert -draw "image under 1,1 0,0 $file1" $file3 $file4
  composite -geometry 0x0+1+1 $file1 $file3 $file4

  pngquant 256 $file4
  mv "$filebase-4-fs8.png" $file5

  rm -f $file1 $file2 $file3 $file4 "$filebase-4-fs8.png"
done

[Prev in Thread] Current Thread [Next in Thread]