Skip to content
Snippets Groups Projects
Commit 83112a8a authored by Andreas Gohr's avatar Andreas Gohr
Browse files

Build the pagetools sprite programatically with imagemagick

This makes it easier to modify or extend the icons in the sprite.
Just place the source files in the pagetools directory and run the build
script.
parent a4380643
No related branches found
No related tags found
No related merge requests found
Showing
with 56 additions and 0 deletions
#!/bin/sh
#
# This script generates a sprite from the unprocessed toolbar icons by combining them
# and overlaying a color layer for the active state
#
# The final sprite is optimized with optipng
#
# The script currently expects a Linux system with current versions of the imagemagick
# and optipng binaries in the path
#
# @author Andreas Gohr <andi@splitbrain.org>
OUT=`dirname $0`
IN="$OUT/pagetools"
if [ ! -d "$IN" ]; then
echo "Input folder $IN not found"
exit 1
fi
if [ -z "$TEMP" ]; then
TEMP="/tmp"
fi
if [ ! -d "$TEMP" ]; then
echo "No temp directory available"
exit 1
fi
# add up all images twice
montage `for X in $IN/*.png; do echo -n "$X $X "; done` -background transparent -tile 1x -geometry 30x45 -gravity north $TEMP/icons.png
# darken the image
convert $TEMP/icons.png \( +clone -fill '#cccccc' -colorize 100% \) -compose multiply -composite $TEMP/darkicons.png
# create the mask to highlight an active icon
convert -size 30x30 xc:'#2b73b7' -gamma 0.7 $TEMP/active.png
# create the full mask
montage `for X in $IN/*.png; do echo -n "$TEMP/active.png "; done` -background transparent -tile 1x -geometry 30x60+0+15 -gravity south $TEMP/activemask.png
# apply mask
convert $TEMP/darkicons.png $TEMP/activemask.png \
\( -clone 0 -alpha extract \) \
\( -clone 0 -clone 1 -compose overlay -composite \) \
-delete 0,1 +swap -alpha off -compose copy_opacity -composite $OUT/pagetools-sprite.png
# optimize final sprite
optipng -o5 $OUT/pagetools-sprite.png
# remove temporary images
rm -f $TEMP/icons.png
rm -f $TEMP/darkicons.png
rm -f $TEMP/active.png
rm -f $TEMP/activemask.png
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment