Blame Scripts/Modules/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 25be94
#   tcar - The CentOS Artwork Repository automation tool.
Alain Reguera Delgado 25be94
#   Copyright © 2014 The CentOS Artwork SIG
Alain Reguera Delgado 2c7b25
#
Alain Reguera Delgado 25be94
#   This program is free software; you can redistribute it and/or
Alain Reguera Delgado 25be94
#   modify it under the terms of the GNU General Public License as
Alain Reguera Delgado 25be94
#   published by the Free Software Foundation; either version 2 of the
Alain Reguera Delgado 25be94
#   License, or (at your option) any later version.
Alain Reguera Delgado 2c7b25
#
Alain Reguera Delgado 25be94
#   This program is distributed in the hope that it will be useful,
Alain Reguera Delgado 25be94
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
Alain Reguera Delgado 25be94
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Alain Reguera Delgado 25be94
#   General Public License for more details.
Alain Reguera Delgado 2c7b25
#
Alain Reguera Delgado 25be94
#   You should have received a copy of the GNU General Public License
Alain Reguera Delgado 25be94
#   along with this program; if not, write to the Free Software
Alain Reguera Delgado 25be94
#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Alain Reguera Delgado 2c7b25
#
Alain Reguera Delgado 25be94
#   Alain Reguera Delgado <al@centos.org.cu>
Alain Reguera Delgado 25be94
#   39 Street No. 4426 Cienfuegos, Cuba.
Alain Reguera Delgado 2c7b25
#
Alain Reguera Delgado 2c7b25
######################################################################
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 25be94
# Standardize extended production of PNG files from SVG files. The
Alain Reguera Delgado 25be94
# extended production consists on producing PNG images in in different
Alain Reguera Delgado 25be94
# formats, heights, foreground colors and background colors.
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
}