Blame Identity/Icons/render.sh

4c79b5
#!/bin/bash
4c79b5
#
4c79b5
# Icons rendering script
4c79b5
#
4c79b5
# Copyright (C) 2009 The CentOS Project 
4c79b5
#
4c79b5
# This program is free software; you can redistribute it and/or modify
4c79b5
# it under the terms of the GNU General Public License as published by
4c79b5
# the Free Software Foundation; either version 2 of the License, or
4c79b5
# (at your option) any later version.
4c79b5
#
4c79b5
# This program is distributed in the hope that it will be useful, but
4c79b5
# WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c79b5
# General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with this program; if not, write to the Free Software
4c79b5
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
4c79b5
# USA
4c79b5
#
4c79b5
#--------------------------------------
4c79b5
# Category: rendering
4c79b5
#--------------------------------------
4c79b5
4c79b5
4c79b5
4c79b5
# Define export id used on templates.
4c79b5
# Not export id used. Take the whole work area.
4c79b5
4c79b5
# Define directory holding templates. It is preferable to point the
4c79b5
# local working directory holding templates in order to let people
4c79b5
# rendering their templates changes locally before commit them up to
4c79b5
# the central repository.
4c79b5
SVG=tpl
4c79b5
4c79b5
# Save images locally. Generally on the working directory, there where
4c79b5
# you can use svn commands.
4c79b5
IMG=img
4c79b5
4c79b5
# Define icon width. Height is calculated automatically.
4c79b5
WIDTHS="16 20 22 24 32 36 40 48 64 96 128 148 164 196 200"
4c79b5
4c79b5
if [ "$1" ];then
4c79b5
   WIDTHS="$1"
4c79b5
fi
4c79b5
4c79b5
# Define category filter
4c79b5
if [ "$2" ]; then
4c79b5
   CATEGORIES=`ls $SVG | egrep "$2"`
4c79b5
else
4c79b5
   CATEGORIES=`ls $SVG`
4c79b5
fi
4c79b5
4c79b5
for CATEGORY in $CATEGORIES; do
4c79b5
4c79b5
   for WIDTH in $WIDTHS; do
4c79b5
4c79b5
      # Check output image directory existence
4c79b5
      if [ ! -d $IMG/$WIDTH/$CATEGORY ];then
4c79b5
         mkdir -p $IMG/$WIDTH/$CATEGORY
4c79b5
      fi
4c79b5
4c79b5
      # Define template filter
4c79b5
      if [ "$3" ]; then
4c79b5
         TEMPLATES=`ls $SVG/$CATEGORY | egrep $3`
4c79b5
      else
4c79b5
         TEMPLATES=`ls $SVG/$CATEGORY`
4c79b5
      fi
4c79b5
4c79b5
      for FILE in $TEMPLATES; do
4c79b5
4c79b5
         # Define template file
4c79b5
         TEMPLATE=$SVG/$CATEGORY/$FILE
4c79b5
4c79b5
         # Define image file
4c79b5
         IMAGE=$IMG/$WIDTH/$CATEGORY/`echo $FILE | sed -e "s!\.tpl!.png!"`
4c79b5
4c79b5
         # Image rendering 
4c79b5
         inkscape $TEMPLATE --export-width=$WIDTH --export-png=$IMAGE
4c79b5
      done
4c79b5
   done
4c79b5
done