|
|
89c95e |
#!/bin/bash
|
|
|
89c95e |
#
|
|
|
89c95e |
# svg_convertPngToBranded.sh -- This function standardizes image
|
|
|
89c95e |
# branding. Once the base PNG image is rendered and the
|
|
|
89c95e |
# `--with-brands' option is provided, this function composites a new
|
|
|
89c95e |
# branded image using the preferences set in the `branding.conf' file.
|
|
|
89c95e |
# The `branding.conf' file must be stored in the design model root
|
|
|
89c95e |
# location used as reference to produce the base PNG image.
|
|
|
89c95e |
#
|
|
|
2fe9b7 |
# Copyright (C) 2009, 2010, 2011 The CentOS Project
|
|
|
89c95e |
#
|
|
|
89c95e |
# This program is free software; you can redistribute it and/or modify
|
|
|
89c95e |
# it under the terms of the GNU General Public License as published by
|
|
|
89c95e |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
89c95e |
# your option) any later version.
|
|
|
89c95e |
#
|
|
|
89c95e |
# This program is distributed in the hope that it will be useful, but
|
|
|
89c95e |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
89c95e |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
89c95e |
# General Public License for more details.
|
|
|
89c95e |
#
|
|
|
89c95e |
# You should have received a copy of the GNU General Public License
|
|
|
89c95e |
# along with this program; if not, write to the Free Software
|
|
|
89c95e |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
89c95e |
#
|
|
|
89c95e |
# ----------------------------------------------------------------------
|
|
|
89c95e |
# $Id$
|
|
|
89c95e |
# ----------------------------------------------------------------------
|
|
|
89c95e |
|
|
|
89c95e |
function svg_convertPngToBranded {
|
|
|
89c95e |
|
|
|
89c95e |
# Verify whether the option `--with-brands' was provided or not to
|
|
|
89c95e |
# `centos-art.sh' script command-line.
|
|
|
89c95e |
if [[ $FLAG_WITH_BRANDS == 'false' ]];then
|
|
|
89c95e |
return
|
|
|
89c95e |
fi
|
|
|
89c95e |
|
|
|
89c95e |
local BRANDING_CONF_FILE=''
|
|
|
89c95e |
local BRANDING_CONF_SECTION=''
|
|
|
89c95e |
local BRANDING_CONF_VALUES=''
|
|
|
89c95e |
local BRANDING_CONF_VALUE=''
|
|
|
89c95e |
local BRAND=''
|
|
|
89c95e |
local POSITION=''
|
|
|
89c95e |
local POSITIONS=''
|
|
|
89c95e |
|
|
|
89c95e |
# Define absolute path to branding configuration file.
|
|
|
89c95e |
BRANDING_CONF_FILE="$(cli_getRepoTLDir)/Identity/Models/Themes/${FLAG_THEME_MODEL}/branding.conf"
|
|
|
89c95e |
|
|
|
89c95e |
# Define regular expression matching the variable name (i.e., the
|
|
|
89c95e |
# left column), inside the configuration line, you want to match
|
|
|
89c95e |
# on.
|
|
|
89c95e |
BRANDING_CONF_VARNAME=$(echo $TEMPLATE | cut -d/ -f10-)
|
|
|
89c95e |
|
|
|
89c95e |
# Define list of configuration lines related to current design
|
|
|
89c95e |
# model. This are the lines that tell us how and where to apply
|
|
|
89c95e |
# branding information on base PNG image. Be sure that only
|
|
|
89c95e |
# configuration lines from supported section names (e.g.,
|
|
|
89c95e |
# `symbol', `type', `logo') be read, no need to waste resources
|
|
|
89c95e |
# with others.
|
|
|
89c95e |
BRANDING_CONF_VALUES=$(\
|
|
|
89c95e |
for BRANDING_CONF_SECTION in $(echo "types symbols logos");do
|
|
|
89c95e |
cli_getConfigValue "${BRANDING_CONF_FILE}" "${BRANDING_CONF_SECTION}" "${BRANDING_CONF_VARNAME}"
|
|
|
89c95e |
done)
|
|
|
89c95e |
|
|
|
89c95e |
for BRANDING_CONF_VALUE in $BRANDING_CONF_VALUES;do
|
|
|
89c95e |
|
|
|
89c95e |
# Define absolute path to image file used as brand. This is
|
|
|
89c95e |
# the image put over the PNG image produced as result of
|
|
|
89c95e |
# design models base rendition.
|
|
|
89c95e |
BRAND="$(cli_getRepoTLDir)/Identity/Images/Brands/$(echo $BRANDING_CONF_VALUE \
|
|
|
89c95e |
| gawk 'BEGIN{ FS=":" } { print $1 }')"
|
|
|
89c95e |
|
|
|
89c95e |
# Verify absolute path to image file used as brand. Assuming
|
|
|
89c95e |
# no brand image file is found, continue with the next
|
|
|
89c95e |
# configuration line.
|
|
|
89c95e |
if [[ ! -f $BRAND ]];then
|
|
|
89c95e |
continue
|
|
|
89c95e |
fi
|
|
|
89c95e |
|
|
|
89c95e |
# Define list of positions using the format of ImageMagick
|
|
|
89c95e |
# `-geometry' option argument.
|
|
|
89c95e |
POSITIONS=$(echo "$BRANDING_CONF_VALUE" | cut -d: -f2- | tr ':' ' ')
|
|
|
89c95e |
|
|
|
89c95e |
# Loop through list of brand image positions and use the
|
|
|
89c95e |
# composite command from ImageMagick, to overlap brand image
|
|
|
89c95e |
# over unbranded image just rendered.
|
|
|
89c95e |
for POSITION in $POSITIONS;do
|
|
|
89c95e |
composite -geometry $POSITION $BRAND ${FILE}.png ${FILE}.png
|
|
|
89c95e |
done
|
|
|
89c95e |
|
|
|
89c95e |
done
|
|
|
89c95e |
|
|
|
89c95e |
}
|