-
-
Save marcusmoller/6622766 to your computer and use it in GitHub Desktop.
#!/bin/sh | |
for f in *.gif | |
do | |
short=${f:0:4} | |
if ls $short".png" &> /dev/null; then | |
echo "file exists" | |
else | |
montage -tile x1 -geometry +0+0 -background none $short*.gif $short.png | |
convert $short.png -transparent white $short.png | |
fi | |
done |
Yeah, I don't think Bourne shell (the original /bin/sh) supports this, and it works many places because the powers-that-be link /bin/sh to /bin/bash or some other advanced Bourne-y shell.
Bash is everywhere, so madmarcel's change would make it more "correct", but you could go the other way too:
short=echo $f | sed -re 's/^(.{4}).+$/\1/'
Though that is a little line-noise-ish. :-)
Thanks for this, marcusmoller!
You can take it one step further and build it into a single texture (using the 256x32 pngs):
montage -tile 4x -geometry +0+0 -background none *.png ../lastguardian-all.png
That will create a 1024x736 png with all the sprites. I put up a copy here:
http://postimg.org/image/mqncja9q9/
Remember to credit him:
... Philipp Lenssen and my website is outer-court.com . An appropriate link to the site and credit by name would be appreciated in your projects.
This will error on ubuntu with "Bad substitution" on line 6
change the first line to
!/bin/bash
and it will work just fine