updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / kdeicons-oxygen-svn / generate_oxy_theme.sh
blob026d6b70b284f6c6c6badeee0b35cbc06f89841b
1 #!/bin/bash
3 # Copyright (C) 2006-2007, Darwin Bautista
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 SMALL_VERSIONS="yes"
21 SIZES="128x128 64x64 48x48 32x32 22x22 16x16"
22 FOLDERS="actions apps devices filesystems mimetypes"
24 usage() {
25 echo "usage: $(basename ${0}) [SVGDIR] [OUTDIR]"
26 exit 1
29 msg() {
30 echo -e "\033[1;32m==>\033[1;0m \033[1;1m$1\033[1;0m" >&2
33 iconcmp() {
34 if [ $(stat -c%Y "${1}" 2> /dev/null) -gt $(stat -c%Y "${2}" 2> /dev/null) ]; then
35 echo 1;
36 else
37 echo 0;
41 create_dir_struct() {
42 for size in ${SIZES}; do
43 for folder in ${FOLDERS}; do
44 mkdir -p ${OXY_DIR}/${size}/${folder}
45 done
46 done
49 cleanup() {
50 rm -R ${OXY_DIR}/128x128/actions
53 convert_small() {
54 for folder in ${FOLDERS}; do
55 for size in $(ls ${SVG_DIR}/${folder}/small 2> /dev/null); do
57 # Determine the unsharp mask to use
58 case "${size}" in
59 "16x16")
60 unsharp_mask="-unsharp 0.3x0.3+0.5"
62 "22x22")
63 unsharp_mask="-unsharp 0.5x0.5+0.5"
66 unsharp_mask=""
68 esac
70 for svg in $(ls ${SVG_DIR}/${folder}/small/${size}/*.{svg,svgz} 2> /dev/null); do
72 png="${svg%.svg}"
73 png="${png%.svgz}.png"
74 png="${OXY_DIR}/${size}/${folder}/${png#${SVG_DIR}/${folder}/small/${size}/}"
76 #if (iconcmp ${svg} ${png}); then
77 # Use Inkscape to convert from SVG to PNG because it's much better at handling SVGs (don't resize, yet)
78 inkscape --without-gui --export-background-opacity=0 --export-dpi=90 --file=${svg} --export-png=${png} >& /dev/null
79 # Now, resize the PNG using ImageMagick
80 convert -filter Sinc -resize ${size} -depth 8 ${unsharp_mask} ${png} ${png} >& /dev/null
81 #fi
82 done
83 done
84 done
87 convert_normal() {
88 for folder in ${FOLDERS}; do
89 for svg in $(ls ${SVG_DIR}/${folder}/*.{svg,svgz} 2> /dev/null); do
91 png="${svg%.svg}"
92 png="${png%.svgz}.png"
93 png="${png#${SVG_DIR}/}"
95 #if (iconcmp ${svg} ${OXY_DIR}/48x48/${png}); then
96 # SVGs -> PNGs
97 inkscape --without-gui --export-background-opacity=0 --export-width=128 --export-height=128 --file=${svg} --export-png=${OXY_DIR}/128x128/${png} >& /dev/null
99 # PNGs -> PNGs
100 [ "$folder" = "actions" ] || convert -filter Sinc -resize 64x64 -depth 8 ${OXY_DIR}/128x128/${png} ${OXY_DIR}/64x64/${png} >& /dev/null
101 if [ "$folder" = "actions" ]; then
102 convert -filter Sinc -resize 48x48 -depth 8 ${OXY_DIR}/128x128/${png} ${OXY_DIR}/48x48/${png} >& /dev/null
103 else
104 convert -filter Sinc -resize 48x48 -depth 8 ${OXY_DIR}/64x64/${png} ${OXY_DIR}/48x48/${png} >& /dev/null
106 [ -f ${OXY_DIR}/32x32/${png} ] || convert -filter Sinc -resize 32x32 -depth 8 ${OXY_DIR}/48x48/${png} ${OXY_DIR}/32x32/${png} >& /dev/null
107 [ -f ${OXY_DIR}/22x22/${png} ] || convert -filter Sinc -resize 22x22 -depth 8 -unsharp 0.5x0.5+0.5 ${OXY_DIR}/32x32/${png} ${OXY_DIR}/22x22/${png} >& /dev/null
108 [ -f ${OXY_DIR}/16x16/${png} ] || convert -filter Sinc -resize 16x16 -depth 8 -unsharp 0.3x0.3+0.5 ${OXY_DIR}/32x32/${png} ${OXY_DIR}/16x16/${png} >& /dev/null
110 done
111 done
114 # Entry point
115 if [ ${#} -ne 2 ]; then
116 usage
119 SVG_DIR="${1}"
120 OXY_DIR="${2}"
122 if [ -z "$(ls ${SVG_DIR}/actions/*.{svg,svgz} 2> /dev/null)" ]; then
123 echo "No SVGs found."
124 exit 1
127 # Create directory structure
128 create_dir_struct
130 # Convert small versions if available
131 if [ "${SMALL_VERSIONS}" = "yes" ]; then
132 msg "Converting smaller versions to PNGs..."
133 convert_small
136 # Convert larger versions to PNGs (except 128x128 and 64x64 actions/*.svg)
137 msg "Converting larger versions to PNGs..."
138 convert_normal
140 cleanup
142 exit 0