I have an image resizer(bottom). Now I want to use it to batch resize pngs. Problem is to run it only once for each file. This snippet creates new images over the created ones:
for image in find . -type f -name "*.png"; do
/Users/dev/scripts/./imre.sh "$image" 200 133
done
Resizer:
#!/bin/bash
###### LOCAL VARIABLES
convert=/usr/bin/convert
identify=/usr/bin/identify
image=$1
heigth=$2
width=$3
usage_message="Usage: imre image heigth width"
usage_example="Example: imre anyImage.png 50 50"
space=""
###### ACTIONS
clear
echo $space
echo "*** START image resizer script ***"
echo $space
if [ -z "$image" ] || [ -z "$heigth" ] || [ -z "$width" ] ;
then
echo $usage_message
echo $space
echo $usage_example
echo $space
echo "*** END image resizer script ***"
echo $space ; exit 1
fi
echo "To modify $image to $heigth x $width (HxW)"
echo "Given image data: "
identify $image
convert $image -resize "${heigth}"x"${width}" $image
echo "$1"
echo $space
echo "*** END image resizer script ***"
echo $space
exit 0
convert "$image" -resize ...- missing$. Also best if you will always quote variables. here are some cases when it isn't needed but in general it is much better...