2 # vim: expandtab sw=4 ts=4 sts=4:
5 if [ -n "$GATEWAY_INTERFACE" ] ; then
6 echo 'Can not invoke as CGI!'
10 # Check for proper number of command line args.
12 echo "Usage: `basename $0` {path_to_pma_root_folder}"
16 # Check if we have ImageMagick
17 hash identify
2>&- ||
{
18 echo "ERROR: ImageMagick not found on the system!"
23 # Compress image, if possible
25 hash pngcrush
2>&- ||
{
27 echo "WARNING: 'pngcrush' not found, will not be able to compress the sprites"
30 # Icons that should not be included in the sprite
31 BLACKLIST
="vertical_line.png spacer.png"
33 # Output filename for the sprite image
36 # Library file that will contain the information about
37 # individual images that are part of the sprite
38 LIBRARY
="../sprites.lib.php"
40 if [ -d $1/themes
]; then
44 for d
in $
(ls -d */); do
45 # Go to folder that contains the images
47 echo "Processing folder: $PWD"
49 for f
in $
(ls *.png| LC_ALL
=C
sort); do
51 # Do not include blacklisted icons
52 for b
in $BLACKLIST; do
53 if [ "$b" = "$f" ]; then
57 if [ $VALID = false
]; then
60 DATA
=$
(identify
-ping $f ||
echo "NULL")
61 if [ "$DATA" != "NULL" ]; then
62 SIZE
=$
(echo $DATA | cut
-d ' ' -f 3 |
sed 's/x/ /')
63 # Do not include icons that are larger than 16x16
65 if [ $s -gt 16 ]; then
69 if [ $VALID = true
]; then
70 # Build the list of valid icons
76 # Create an empty sprite of the correct size
79 NUM_FILES
=$
(($NUM_FILES+1))
81 convert
-size 16x$
(($NUM_FILES*16+16)) xc
:none temp.png
83 # Add each icon to the sprite
86 convert temp.png
$f -geometry +0+$
(($CURRENT*16)) -composite temp.png
87 CURRENT
=$
(($CURRENT+1))
90 # Compress image, if possible
91 if [ $HAVE_PNGCRUSH -eq 1 ]; then
92 echo "Compressing file: $PWD/$OUTPUT"
93 pngcrush
-brute temp.png
$OUTPUT > /dev
/null
99 # Generate the library file that contains the information
100 # about individual images that are part of the sprite
101 echo '<?php' > $LIBRARY
102 echo '/**' >> $LIBRARY
103 echo ' * AUTOGENERATED CONTENT - DO NOT EDIT!' >> $LIBRARY
104 echo ' * ALL CHANGES WILL BE UNDONE!' >> $LIBRARY
105 echo ' * RUN `./scripts/generate-sprites` TO UPDATE THIS FILE' >> $LIBRARY
106 echo ' *' >> $LIBRARY
107 echo ' * @package PhpMyAdmin-theme' >> $LIBRARY
108 echo ' */' >> $LIBRARY
110 echo '/**' >> $LIBRARY
111 echo ' * Map of sprites inside sprite.png' >> $LIBRARY
112 echo ' */' >> $LIBRARY
113 echo "\$sprites = array(" >> $LIBRARY
116 # Add a CSS rule for each icon in the sprite
117 NAME
=$
(echo "'$f'" |
sed 's/\.png//')
119 DATA
=$
(identify
-ping $f ||
echo "NULL")
120 if [ "$DATA" != "NULL" ]; then
121 SIZE
=$
(echo $DATA | cut
-d ' ' -f 3 |
sed 's/x/ /')
125 if [ $WIDTH = 0 ]; then
132 echo " $NAME => array(" >> $LIBRARY
133 echo " 'position' => '$CURRENT'," >> $LIBRARY
134 echo " 'width' => '$WIDTH'," >> $LIBRARY
135 echo " 'height' => '$HEIGHT'" >> $LIBRARY
136 echo " )," >> $LIBRARY
137 CURRENT
=$
(($CURRENT+1))
139 echo ");" >> $LIBRARY
141 # Back to the parent folder
146 echo "ERROR: could not find the 'themes' folder in '`readlink -f $1`'"