Author: alink
Date: Fri Mar 27 19:19:56 2009
New Revision: 34187
URL: http://svn.gna.org/viewcvs/wesnoth?rev=34187&view=rev
Log:
A basic shell script to find the number of pixels out of the hex in unit images
Added:
trunk/data/tools/hexometer/
trunk/data/tools/hexometer/alphamask.png (with props)
trunk/data/tools/hexometer/hexometer (with props)
Added: trunk/data/tools/hexometer/alphamask.png
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/hexometer/alphamask.png?rev=34187&view=auto
==============================================================================
Binary file - no diff available.
Propchange: trunk/data/tools/hexometer/alphamask.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: trunk/data/tools/hexometer/hexometer
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/hexometer/hexometer?rev=34187&view=auto
==============================================================================
--- trunk/data/tools/hexometer/hexometer (added)
+++ trunk/data/tools/hexometer/hexometer Fri Mar 27 19:19:56 2009
@@ -1,0 +1,136 @@
+#!/bin/sh
+scriptname="hexometer"
+help ()
+{
+ echo "Search png images not fitting in a hex"
+ echo
+ echo "$scriptname [option] [directory1 directory2 ...]"
+ echo "-m, --mask file choose which image use as mask"
+ echo " (default = alphamask.png)"
+ echo "-a, --anim skip most animations images (containing:"
+ echo " -attack -defend -melee -ranged -magic
-idle"
+ echo " -die -dying -death -healing -flying
-leading)"
+ echo "-s, --suffix skip images with directional or numerical
suffix"
+ echo "-r, --regex REG skip images matching the case-insensitive"
+ echo " regular expression REG (posix-extended)"
+ echo "-f, --format skip images which are not in 72x72 format"
+ echo "-q, --quiet only display results"
+ echo
+ echo "return numbers of pixels out of the hex for each filename"
+ echo "(-1 if the image is not a standard 72x72 image and -f was not
used"
+}
+
+mask="alphamask.png"
+format=0
+quiet=0
+
+regex=""
+suffix=".*(-n|-s|-w|-e|-ne|-nw|-sw|-se|-[0-9]+)(-|[.]).*"
+anim=".*-attack.*|.*-defend.*|.*-melee.*|.*-ranged.*|.*-magic.*|.*-idle.*|.*-die.*|.*-dying.*|.*-death.*|.*-flying.*|.*-leading.*|.*-healing.*"
+
+until [ -z "$1" ]
+do
+ if [ "$1" == "--help" -o "$1" == "-h" ]
+ then
+ help
+ exit
+ fi
+
+ if [ "$1" == "--mask" -o "$1" == "-m" ]
+ then
+ shift
+ mask="$1"
+ shift
+ continue
+ fi
+
+ if [ "$1" == "--regex" -o "$1" == "-r" ]
+ then
+ shift
+ regex="$regex|$1"
+ shift
+ continue
+ fi
+
+ if [ "$1" == "--anim" -o "$1" == "-a" ]
+ then
+ regex="$regex|$anim"
+ shift
+ continue
+ fi
+
+ if [ "$1" == "--suffix" -o "$1" == "-s" ]
+ then
+ regex="$regex|$suffix"
+ shift
+ continue
+ fi
+
+ if [ "$1" == "--format" -o "$1" == "-f" ]
+ then
+ format=1
+ shift
+ continue
+ fi
+
+ if [ "$1" == "--quiet" -o "$1" == "-q" ]
+ then
+ quiet=1
+ shift
+ continue
+ fi
+
+ # record all given directories
+ dir="$dir $1"
+ shift
+
+done
+
+# if no directory, use current
+if [ "$dir" == "" ]
+then
+ dir='.'
+fi
+
+if [ ! -r $mask ]
+then
+ echo "$scriptname : cannot access $mask : No such file or directory "
+ exit 1
+fi
+
+
+if [ "$quiet" == 0 ]
+then
+ echo "Search 72x72 images not fitting in a hex"
+ echo "in directories : $dir"
+ echo "Using alphamask image : $mask"
+ echo "Skipping files matching regex: $regex"
+ echo "Pixels out of hex : filename"
+fi
+
+test_img()
+{
+ if [ `identify -format "%wx%h" $img` != '72x72' ]
+ then
+ if [ $format == 0 ]
+ then
+ px=-1
+ else
+ # mark as ok, because user want to skip bad format
+ px=0
+ fi
+ else
+ px=`composite $mask $img /tmp/tmp_result.png && compare
-channel alpha -metric AE $mask /tmp/tmp_result.png /dev/null 2>&1 `
+ fi
+
+ if [ "$px" != 0 ]
+ then
+ echo -e "$px\t : $img"
+ fi
+}
+
+find $dir -regextype posix-extended -name '*.png' -and -not -iregex "$regex" \
+ -print | sort | while read img; do test_img; done
+
+rm -f /tmp/tmp_result.png
+exit
Propchange: trunk/data/tools/hexometer/hexometer
------------------------------------------------------------------------------
svn:executable = *
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits