| Re: [hatari-devel] hatari-ui icon | 
[ Thread Index | 
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
] 
Hi,
Attached is a generic script for app icon scaling
(most of it is error handling...).
	- Eero
On keskiviikko 05 marraskuu 2014, Eero Tamminen wrote:
> On tiistai 04 marraskuu 2014, Thomas Huth wrote:
> > So I guess we need some additional logic in the CMakeLists.txt to scale
> > it to other sizes, too. Does anybody know a good solution?
> > Maybe "convert" from image-magick?
> 
> Something like this works OK:
> 	srcimg=<name>.png
> 	for size in 256x256 64x64 48x48 24x24; do
> 		mkdir $size
> 		convert $srcimg -resize $size $size/hatari.png
> 	done
#!/bin/sh
usage ()
{
	name=${0##*/}
	echo "usage: $name <app name> <source image> <icon dir> <size> [size [size...]]" 1>&2
	echo 1>&2
	echo "example: $name hatari test.jpg /usr/share/icons/hicolor 64x64 48x48" 1>&2
	echo " -> /usr/share/icons/hicolor/64x64/apps/hatari.png" 1>&2
	echo " -> /usr/share/icons/hicolor/48x48/apps/hatari.png" 1>&2
	echo 1>&2
	echo "ERROR: $1!" 1>&2
	exit 1
}
if [ $# -lt 4 ]; then
	usage "not enough arguments"
fi
name=$1
shift
if [ \! -f "$1" ]; then
	usage "source image file '$1' doesn't exist"
fi
srcimg=$1
shift
if [ \! -d "$1" ] || [ \! -w "$1" ]; then
	usage "destination icon directory '$1' doesn't exist, or it's not writable"
fi
dstdir=$1
shift
convert=$(which convert)
if [ -z "$convert" ]; then
	usage "'convert' tool missing, please install imagemagick"
fi
for size in $*; do
	mkdir -p $dstdir/$size/apps
	cmd="convert $srcimg -resize $size $dstdir/$size/apps/$name.png"
	echo $cmd
	$cmd
done