Blame tcar-scripts-render/modules/files/modules/svg/svg_setBaseRendition.sh

Alain Reguera Delgado 2c7b25
#!/bin/bash
Alain Reguera Delgado 2c7b25
######################################################################
Alain Reguera Delgado 2c7b25
#
Alain Reguera Delgado 2c7b25
#   svg_setBaseRendition.sh -- This function standardizes the base
Alain Reguera Delgado 2c7b25
#   rendition tasks needed to produce PNG files from SVG files.
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 svg_setBaseRendition {
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
    local COUNTER=0
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
    local -a SOURCE_INSTANCES
Alain Reguera Delgado 2c7b25
    local -a TARGET_INSTANCES
Alain Reguera Delgado 2c7b25
    local -a INKSCAPE_OPTIONS
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
    while [[ ${COUNTER} -lt ${#SOURCES[*]} ]];do
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
        render_setInstances "${SOURCES[${COUNTER}]}" '(svgz|svg)' 'png'
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
        render_setLocalizedXml "${SOURCES[${COUNTER}]}" "${SOURCE_INSTANCES[${COUNTER}]}"
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
        tcar_setTranslationMarkers ${SOURCE_INSTANCES[${COUNTER}]}
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
        svg_checkModelAbsref "${SOURCE_INSTANCES[${COUNTER}]}"
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
        svg_setBaseRenditionOptions
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
        svg_setBaseRenditionCommand
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
        COUNTER=$(( ${COUNTER} + 1 ))
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
    done
Alain Reguera Delgado 2c7b25
    
Alain Reguera Delgado 2c7b25
    # Verify existence of output directory.
Alain Reguera Delgado 2c7b25
    if [[ ! -d $(dirname ${RENDER_TARGET}) ]];then
Alain Reguera Delgado 2c7b25
        mkdir -p $(dirname ${RENDER_TARGET})
Alain Reguera Delgado 2c7b25
    fi
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
    tcar_printMessage "${RENDER_TARGET}" --as-creating-line
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
    # Apply command to PNG images produced from design models to
Alain Reguera Delgado 2c7b25
    # construct the final PNG image.
Alain Reguera Delgado 2c7b25
    if [[ -n ${COMMAND} ]];then
Alain Reguera Delgado 2c7b25
        ${COMMAND} ${TARGET_INSTANCES[*]} ${RENDER_TARGET}
Alain Reguera Delgado 2c7b25
    fi
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
    # Apply branding images to final PNG image.
Alain Reguera Delgado 2c7b25
    if [[ -n ${BRANDS} ]];then
Alain Reguera Delgado 2c7b25
        svg_setBrandInformation
Alain Reguera Delgado 2c7b25
    fi
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
    # Apply comment to final PNG image.
Alain Reguera Delgado 2c7b25
    if [[ -n ${COMMENT} ]];then
Alain Reguera Delgado 2c7b25
        /usr/bin/mogrify -comment "${COMMENT}" ${RENDER_TARGET}
Alain Reguera Delgado 2c7b25
    fi
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
    # Remove instances to save disk space. There is no need to have
Alain Reguera Delgado 2c7b25
    # unused files inside the temporal directory. They would be
Alain Reguera Delgado 2c7b25
    # consuming space unnecessarily. Moreover, there is a remote
Alain Reguera Delgado 2c7b25
    # chance of name collapsing (because the huge number of files that
Alain Reguera Delgado 2c7b25
    # would be in place and the week random string we are putting in
Alain Reguera Delgado 2c7b25
    # front of files) which may produce unexpected results.
Alain Reguera Delgado 2c7b25
    rm ${TARGET_INSTANCES[*]} ${SOURCE_INSTANCES[*]}
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
    # Unset array variables and their counter to prevent undesired
Alain Reguera Delgado 2c7b25
    # concatenations.
Alain Reguera Delgado 2c7b25
    unset SOURCE_INSTANCES
Alain Reguera Delgado 2c7b25
    unset TARGET_INSTANCES
Alain Reguera Delgado 2c7b25
    unset INKSCAPE_OPTIONS
Alain Reguera Delgado 2c7b25
    unset COUNTER
Alain Reguera Delgado 2c7b25
Alain Reguera Delgado 2c7b25
}