[ICONS] tool to create icons from svg

Hervÿffffe9 Chanal chanal_herve at yahoo.fr
Wed Jan 9 07:56:25 CST 2008


The exported size are 16 22 24 32 48
It is based on the font_convert.sh file and the Frank Richter file
It use :
- The inkscape png export (because convert gives awfull results)
- Image Magick to decrease the color depth
- Icotool to generate the windows icons

Comments are welcome !

Herve Chanal
---
 tools/icon_convert.sh |  125 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 125 insertions(+), 0 deletions(-)
 create mode 100644 tools/icon_convert.sh

diff --git a/tools/icon_convert.sh b/tools/icon_convert.sh
new file mode 100644
index 0000000..8beb3d3
--- /dev/null
+++ b/tools/icon_convert.sh
@@ -0,0 +1,125 @@
+#! /bin/bash
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+#
+
+# default settings
+TMPDIR=/tmp/iconv.$$;
+if [ -f `which mktemp` ]; then
+  TFILE=`mktemp -q /tmp/iconv.XXXXXX`
+else
+  TFILE=`tempfile`;
+fi
+
+FC=inkscape;
+CONV=convert;
+ICOG=icotool;
+PAT="*.svg";
+CDEPTH=256;
+TARGET=`pwd`;
+
+
+# Icon sizes to generate/use:
+# 16 - Windows small icon (Window menu, start menu)
+# 22 - Small icon for KDE and GNOME menus
+# 24 - Small icon for GNOME file lists(*)
+# 32 - Normal icon for Windows
+# 48 - Large icon for Windows XP
+# 128 - MacOS/X, some Windows Explorer alternatives use that(**)
+# 256 - Windows Vista icon(**)
+#
+# (**) : not generated here
+SIZE=( 16 22 24 32 48 );
+
+usage () {
+    echo "usage: "`basename $0`" [-q] [-c charset] [-t fontdir] [-b bdftopcf] [-f fnt2bdf]"
+    echo "       [-p pattern] windir"
+    echo
+    echo "This utility scans a directory and its subdirectories for svg file"
+    echo "and convert them into a windows icon."
+    echo
+    echo "options:"
+    echo " -q             quiet operation."
+    echo " -c colordepth  charset name for OEM_CHARSET fonts, default: $CDEPTH"
+    echo " -t icondir     directory to install the icons in. This"
+    echo "                directory should be a known fontdirectory to X, default:"
+    echo "                $TARGET";
+    echo " -p pattern     Shell-Pattern of the filenames to look for. By default, the"
+    echo "                utility will look for the pattern "$PAT" (case insensitive)."
+    echo " windir         base directory to search."
+    exit 1;
+}
+
+
+while [ "$1" ]; do
+    case $1 in
+    -t ) shift; if [ "$1" ]; then TARGET=$1; shift; else usage; fi; ;;
+    -p ) shift; if [ "$1" ]; then PAT=$1; shift; else usage; fi; ;;
+    -c ) shift; if [ "$1" ]; then CDEPTH=$1; shift; else usage; fi; ;;
+        -q ) shift; Q=":"; ;;
+    -* ) echo usage; ;;
+    * ) if [ "$WIND" ]; then usage; else WIND=$1; shift; fi; ;;
+    esac;
+done;
+
+if [ ! "$WIND" ]; then usage; fi;
+if [ ! -d "$WIND" ]; then $Q echo "$WIND is not a directory"; exit 1; fi;
+if [ ! -d "$TARGET" ]; then $Q echo "$TARGET is not a directory"; exit 1; fi;
+type -p $FC   1>/dev/null || { $Q echo "Can't execute svg conversion program : $FC"; exit 1; }
+type -p $CONV 1>/dev/null || { $Q echo "Can't execute color reduction program : $CONV"; exit 1; }
+type -p $ICOG 1>/dev/null || { $Q echo "Can't execute icon creation program : $ICOG"; exit 1; }
+
+$Q echo -n "Looking for svg icons (\"$PAT\") in directory \"$WIND\"... ";
+ICONS=`find $WIND -iname "$PAT" 1>$TFILE 2>/dev/null`;
+if [ $? -ne 0 ]; then
+    $Q echo "$PAT is an invalid search expression"; exit 1;
+fi;
+i=0;
+
+{ while read dummy; do ICONS[$i]="$dummy"; i=$[$i+1]; done; } < $TFILE
+rm $TFILE;
+$Q echo "done."
+
+if [ -z "$ICONS" ]; then $Q echo "Can't find any icons in $WIND"; exit 1; fi;
+
+mkdir "$TMPDIR"
+for i in "${ICONS[@]}"; do cp $i $TMPDIR; done
+cd "$TMPDIR"
+
+for i in "${ICONS[@]}"; do
+    ICN=`basename "$i"`; ICN=${ICN%.???};
+    $Q echo "converting $i to png";
+    for j in "${SIZE[@]}"; do
+      if [ "$Q" ]; then
+      $FC -w $j -h $j -e "step1.png" "$i" 1>/dev/null 2>/dev/null;
+      else
+      $FC -w $j -h $j -e "step1.png" "$i";
+      fi;
+      $CONV "step1.png" -compose CopyOpacity -composite -colors $CDEPTH -dither "ico_$j.png";
+    done;
+
+    $Q echo "converting $i to ico";
+    if [ "$Q" ]; then
+      icotool -c -o "step2.ico" ico_*.png 2>/dev/null;
+    else
+      icotool -c -o "step2.ico" ico_*.png;
+    fi;
+    cp "step2.ico" "${i%.???}.ico";
+done;
+
+cd $TARGET
+rm -rf "$TMPDIR"
+
+
-- 
1.5.2.5





      _____________________________________________________________________________ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail http://mail.yahoo.fr




More information about the wine-patches mailing list