OK - stackoverflow has numerous multiline answers to my conundrum, none of which seem to work in my use case…
I’ve got a shell script - it verifies that it’s called with 2 arguments… It then verifies the $2 argument is a number between one, and three :
if [ $SIZIO -lt 1 ] && [ $SIZIO -gt 3 ] ; then
echo "1 = 5%, 2 = 7%, 3 = 10% - THERE ARE NO OTHER >>ACCEPTABLE<< VALUES MORON!"
exit 1
fi
Tried this - but it doesn’t work :
# if ! [[ $1 =~ '^[0-9]+$' ]] ; then
# echo "That crap's not a number dipshit..." ;
# exit 1
# fi
Ideally - I’d like to make my if statement an and then or, condition e.g. :
if [ $SIZIO -lt 1 ] && [ $SIZIO -gt 3 ] || [ ! $SIZIO >>>integer<<< ]; then
echo "1 = 5%, 2 = 7%, 3 = 10% - THERE ARE NO OTHER >>ACCEPTABLE<< VALUES MORON!"
exit 1
fi
i.e. three conditions to NOT exit - the last (or - with “||”) to test if the value’s an integer…
What the script actually does is it takes an image file, reduces it, then blows it up, using “scale” not “resize” in imagemagick, “scale” does a better job at pixelating bitmaps, “resize” is smart - but it tries various stuff for LESS pixelization! I want some pixelization - so that it looks like something from a 256 colour 320x240 MS-DOS game from 1991 or whatever - think Prince of Persia or Commander Keen…
I use a case statement :
case $SIZIO in
1)
VAL="5"
;;
2)
# because sometimes 5% is too much, but 10% is not enough
VAL="7"
;;
3)
VAL="10"
;;
# anything else situation probably redundant
*)
echo "not a number ya gitmoron!"
exit 1
;;
esac
to verify and set the “scale” $VAL, this kinda sorta works, but the shell script barfs completely, if I type e.g. “a”, the script crashes out ungracefully :
This is not about obscuring stuff or whatever (i.e. pixelating people’s faces from photos), it’s about creating Pixel Art (which I happen to be a fan of - used to spend hours and hours in DeluxePaint). Been creating stuff in InkScape, plans for a webcomic thingie, I’ve been mulling over…