Blame Automation/Modules/Render/Svg/svg_convertPngToIcons.sh

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