Blame tcar-scripts-render/modules/Files/Modules/Svg/Modules/Extended/extended.sh

Alain Reguera Delgado 2c7b25
#!/bin/bash
Alain Reguera Delgado 2c7b25
######################################################################
Alain Reguera Delgado 2c7b25
#
Alain Reguera Delgado 2c7b25
#   extended.sh -- This function standardize extended production of
Alain Reguera Delgado 2c7b25
#   PNG files from SVG files. The extended production consists on
Alain Reguera Delgado 2c7b25
#   producing PNG images in in different formats, heights, foreground
Alain Reguera Delgado 2c7b25
#   colors and background colors.
Alain Reguera Delgado 2c7b25
#
Alain Reguera Delgado 2c7b25
#   Written by:
Alain Reguera Delgado 2c7b25
#   * Alain Reguera Delgado <al@centos.org.cu>, 2009-2013
Alain Reguera Delgado 2c7b25
#
Alain Reguera Delgado 2c7b25
# Copyright (C) 2009-2013 The CentOS Artwork SIG
Alain Reguera Delgado 2c7b25
#
Alain Reguera Delgado 2c7b25
# This program is free software; you can redistribute it and/or modify
Alain Reguera Delgado 2c7b25
# it under the terms of the GNU General Public License as published by
Alain Reguera Delgado 2c7b25
# the Free Software Foundation; either version 2 of the License, or (at
Alain Reguera Delgado 2c7b25
# your option) any later version.
Alain Reguera Delgado 2c7b25
#
Alain Reguera Delgado 2c7b25
# This program is distributed in the hope that it will be useful, but
Alain Reguera Delgado 2c7b25
# WITHOUT ANY WARRANTY; without even the implied warranty of
Alain Reguera Delgado 2c7b25
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Alain Reguera Delgado 2c7b25
# General Public License for more details.
Alain Reguera Delgado 2c7b25
#
Alain Reguera Delgado 2c7b25
# You should have received a copy of the GNU General Public License
Alain Reguera Delgado 2c7b25
# along with this program; if not, write to the Free Software
Alain Reguera Delgado 2c7b25
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Alain Reguera Delgado 2c7b25
#
Alain Reguera Delgado 2c7b25
######################################################################
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
function extended {
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
    # Retrieve formats you want to produce the image for. This
Alain Reguera Delgado 2c7b25
    # variable contains one or more image format supported by
Alain Reguera Delgado 2c7b25
    # ImageMagick.  For example, `xpm', `jpg', 'tiff', etc.
Alain Reguera Delgado 2c7b25
    local FORMATS=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "formats")
Alain Reguera Delgado 2c7b25
    if [[ -z ${FORMATS} ]];then
Alain Reguera Delgado 2c7b25
        FORMATS="png"
Alain Reguera Delgado 2c7b25
    fi
Alain Reguera Delgado 2c7b25
        
Alain Reguera Delgado 2c7b25
    # Retrieve heights you want to produce the image for. This
Alain Reguera Delgado 2c7b25
    # variable contains one or more numerical values. For example,
Alain Reguera Delgado 2c7b25
    # `16', `24', `32', etc.
Alain Reguera Delgado 2c7b25
    local HEIGHTS=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "heights")
Alain Reguera Delgado 2c7b25
    if [[ -z ${HEIGHTS} ]];then
Alain Reguera Delgado 2c7b25
        HEIGHTS="16 20 22 24 26 32 36 38 40 48 52 64 72 78 96 112 124 128 148 164 196 200 512"
Alain Reguera Delgado 2c7b25
    fi
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
    # Retrieve foreground colors you want to produce the image for.
Alain Reguera Delgado 2c7b25
    # This variable contains one or more color number in hexadecimal
Alain Reguera Delgado 2c7b25
    # format. For example, `000000', `ffffff', etc.
Alain Reguera Delgado 2c7b25
    local FGCOLORS=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "fgcolors")
Alain Reguera Delgado 2c7b25
    if [[ -z ${FGCOLORS} ]];then
Alain Reguera Delgado 2c7b25
        FGCOLORS="000000"
Alain Reguera Delgado 2c7b25
    fi
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
    # Retrieve background colors you want to produce the image for.
Alain Reguera Delgado 2c7b25
    # This variable contains one or more color number in hexadecimal
Alain Reguera Delgado 2c7b25
    # format with opacity information included.  Opacity is specified
Alain Reguera Delgado 2c7b25
    # between 0.0 and 1.0 where 0.0 is full transparency and 1.0 full
Alain Reguera Delgado 2c7b25
    # opacity. For example, the following values are accepted:
Alain Reguera Delgado 2c7b25
    # `000000-0', `ffffff-1', etc.
Alain Reguera Delgado 2c7b25
    local BGCOLORS=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "bgcolors") 
Alain Reguera Delgado 2c7b25
    if [[ -z ${BGCOLORS} ]];then
Alain Reguera Delgado 2c7b25
        BGCOLORS="ffffff-0 ffffff-1"
Alain Reguera Delgado 2c7b25
    fi
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
    for BGCOLOR in ${BGCOLORS};do
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
        # Verify value passed as background color.
Alain Reguera Delgado 2c7b25
        tcar_checkFiles -m '^[a-fA-F0-9]{6}-(0|1)$' ${BGCOLOR}
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
        for FGCOLOR in ${FGCOLORS};do
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
            # Verify value passed as foreground color.
Alain Reguera Delgado 2c7b25
            tcar_checkFiles -m '^[a-fA-F0-9]{3,6}$' ${FGCOLOR}
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
            for HEIGHT in ${HEIGHTS};do
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
                # Verify value passed as height.
Alain Reguera Delgado 2c7b25
                tcar_checkFiles -m '^[[:digit:]]+$' ${HEIGHT}
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
                # Do base rendition actions.
Alain Reguera Delgado 2c7b25
                extended_setBaseRendition
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
            done
Alain Reguera Delgado 2c7b25
        done
Alain Reguera Delgado 2c7b25
    done
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
}