Blame Scripts/Bash/Functions/Render/Svg/svg_convertPngToIcons.sh

878a2b
#!/bin/bash
878a2b
#
878a2b
# svg_convertPngToIcons.sh -- This function provides post-rendition
878a2b
# actions to produce icon images in different sizes and formats from
878a2b
# the same SVG design model.
878a2b
#
878a2b
# Copyright (C) 2009, 2010, 2011 The CentOS Project
878a2b
#
878a2b
# This program is free software; you can redistribute it and/or modify
878a2b
# it under the terms of the GNU General Public License as published by
878a2b
# the Free Software Foundation; either version 2 of the License, or (at
878a2b
# your option) any later version.
878a2b
#
878a2b
# This program is distributed in the hope that it will be useful, but
878a2b
# WITHOUT ANY WARRANTY; without even the implied warranty of
878a2b
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
878a2b
# General Public License for more details.
878a2b
#
878a2b
# You should have received a copy of the GNU General Public License
878a2b
# along with this program; if not, write to the Free Software
878a2b
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
878a2b
#
878a2b
# ----------------------------------------------------------------------
878a2b
# $Id$
878a2b
# ----------------------------------------------------------------------
878a2b
878a2b
function svg_convertPngToIcons {
878a2b
878a2b
    # Define height dimensions you want to produce brands for.
878a2b
    local SIZE=""
878a2b
    local SIZES="16 20 22 24 32 36 40 48 64 96 128 148 164 196 200 512"
878a2b
878a2b
    # Define image formats you want to produce brands for.
878a2b
    local FORMAT=""
878a2b
    local FORMATS=""
878a2b
878a2b
    for SIZE in ${SIZES};do
878a2b
878a2b
        # Redefine absolute path to file location where size-specific
878a2b
        # images will be stored in.
878a2b
        local FINALFILE=$(dirname $FILE)/${SIZE}/$(basename $FILE)
878a2b
878a2b
        # Prepare directory where size-specific images will be stored
878a2b
        # in. If it doesn't exist create it.
878a2b
        if [[ ! -d $(dirname $FINALFILE) ]];then
878a2b
            mkdir -p $(dirname $FINALFILE)
878a2b
        fi
878a2b
878a2b
        # Print action message.
878a2b
        cli_printMessage "${FINALFILE}.png" --as-creating-line
878a2b
878a2b
        # Create size-specific PNG image ommiting all output.
878a2b
        inkscape $INSTANCE --export-id=$EXPORTID \
878a2b
            --export-png=${FINALFILE}.png --export-height=${SIZE} \
878a2b
            &> /dev/null
878a2b
878a2b
        #for FORMAT in ${FORMATS};do
878a2b
        #
878a2b
        #    # Print action message.
878a2b
        #    cli_printMessage "${FINALFILE}.${FORMAT}" --as-creating-line
878a2b
        #
878a2b
        #    # Convert size-specific PNG image into different formats.
878a2b
        #    convert ${FINALFILE}.png ${FINALFILE}.${FORMAT}
878a2b
        #
878a2b
        #done
878a2b
878a2b
        # Create copy of size-specific image in 2 colors.
878a2b
        #cli_printMessage "${FINALFILE}.xbm" --as-creating-line
878a2b
        #convert -colorspace gray -colors 2 ${FINALFILE}.png ${FINALFILE}.xbm
878a2b
878a2b
        # Create copy of size-specific image with emboss effect.
878a2b
        #cli_printMessage "${FINALFILE}-emboss.png" --as-creating-line
878a2b
        #convert -emboss 1 ${FINALFILE}.png ${FINALFILE}-emboss.png
878a2b
878a2b
    done
878a2b
878a2b
}