1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
#!/bin/sh
#
CONVERT=${CONVERT:-convert}
COMPOSITE=${COMPOSITE:-composite}
INKSCAPE=${INKSCAPE:-inkscape}
PPMTOWINICON=${PPMTOWINICON:-ppmtowinicon}
do_inkscape=yes
do_convert=yes
do_winicon=yes
usage() {
cat << EOF
$0 -- Regenerate desktop icon files and windows icon files
Options
--help Displays this message and exits
--skip-png Skips the regeneration of the .png file(s)
--skip-winicon Skips the regneration of the Windows icon file(s)
EOF
}
while test $# -ne 0 ; do
case $1 in
--help)
usage
exit 0
;;
--skip-png)
do_inkscape=no
shift
;;
--skip-winicon)
do_convert=no
do_winicon=no
shift
;;
-*)
echo "$0: Unknown option $1"
usage
exit 1
;;
*)
break
;;
esac
done
if test $? -ne 0 ; then
usage
exit 1
fi
##
## Export the SVG graphics
##
# see if we have inkscape
if test $do_inkscape = yes ; then
${INKSCAPE} --version 2>&1 >/dev/null
if test $? -ne 0 ; then
echo "\"${INKSCAPE} --version\" failed."
echo "Make sure that inkscape is installed and functional on your system."
echo "Skipping the SVG -> PNG conversion."
do_inkscape=no
fi
fi
if test $do_inkscape = yes ; then
echo "Export SVG graphics to png..."
for r in 16 22 24 32 48 ; do
case ${r} in
24)
x=-1
y=23
rs=22
;;
*)
x=0
y=${r}
rs=${r}
;;
esac
for f in *-${rs}.svg ; do
fb=`basename ${f} ${rs}.svg`
p="${fb}${r}.png"
echo "${f} -> ${p}"
${INKSCAPE} --export-png=${p} --export-area=${x}:${x}:${y}:${y} ${f}
done
done
fi
##
## Generate the windows icon file
##
app_icon="application-x-pcb-layout"
if test $do_convert = yes ; then
# see if we have ImageMagick
${CONVERT} --version 2>&1 >/dev/null
if test $? -ne 0 ; then
echo "\"${CONVERT} --version\" failed."
echo "Make sure that ImageMagick is installed and functional on your system."
echo "Skipping the PNG -> PPM conversion."
do_convert=no
fi
fi
if test $do_convert = yes ; then
echo "Creating windows pbm mask files..."
${CONVERT} -channel matte -separate +matte ${app_icon}-48.png - |
${CONVERT} -threshold 65534 -negate - 48_mask.pbm
${CONVERT} -channel matte -separate +matte ${app_icon}-32.png - |
${CONVERT} -threshold 65534 -negate - 32_mask.pbm
${CONVERT} -channel matte -separate +matte ${app_icon}-16.png - |
${CONVERT} -threshold 65534 -negate - 16_mask.pbm
echo "Creating windows ppm flattened files..."
${CONVERT} -flatten -colors 16 ${app_icon}-48.png 48_16.ppm
${CONVERT} -flatten -colors 256 ${app_icon}-48.png 48_256.ppm
${CONVERT} -flatten -colors 16 ${app_icon}-32.png 32_16.ppm
${CONVERT} -flatten -colors 256 ${app_icon}-32.png 32_256.ppm
${CONVERT} -flatten -colors 16 ${app_icon}-16.png 16_16.ppm
${CONVERT} -flatten -colors 256 ${app_icon}-16.png 16_256.ppm
fi
# see if we have netpbm
if test $do_winicon = yes ; then
${PPMTOWINICON} --version 2>&1 >/dev/null
if test $? -ne 0 ; then
echo "\"${PPMTOWINICON} --version\" failed."
echo "Make sure that netpbm is installed and functional on your system."
echo "Skipping the pbm -> windows icon conversion."
do_winicon=no
fi
fi
if test $do_winicon = yes ; then
echo "Creating windows icon file..."
${PPMTOWINICON} -output pcb_icon.ico -andpgms\
48_16.ppm 48_mask.pbm 48_256.ppm 48_mask.pbm\
32_16.ppm 32_mask.pbm 32_256.ppm 32_mask.pbm\
16_16.ppm 16_mask.pbm 16_256.ppm 16_mask.pbm
fi
rm -f \
48_16.ppm 48_256.ppm 48_mask.pbm\
32_16.ppm 32_256.ppm 32_mask.pbm\
16_16.ppm 16_256.ppm 16_mask.pbm
echo "All done"
|