Resize and watermark images using Imagemagick

Tina resizedThis is a modified version of my Resize of images in a folder with imagemagick post back in February. Only difference this time is that i strips out EXIF tags and the script has been cleaned up a bit. Click on the image to see the result in full size.

#!/bin/bash

# Description:
# Script to resize JPG images to desired width defined in IMAGESIZE variable.
# EXIF tags is also removed from the result images.
# Software needed:
# jhead - http://www.sentex.net/~mwandel/jhead/
# imagemagick - http://www.imagemagick.org

IMAGESIZE="320 480"
for IMAGEFILE in $(ls|grep JPG)
do
        for I in $IMAGESIZE
        do
                # create directories if needed
                if [ ! -d $I ]
                then
                        mkdir $I
                fi

                # Strip EXIF tag information from source file
                jhead -purejpg $IMAGEFILE

                # Resize file
                base=`basename $IMAGEFILE .JPG`_Resized_$I.JPG
                convert $IMAGEFILE -resize $I $base

                # Watermark the file
                width=`identify -format %w $base`
                convert -background '#0008' -fill white -gravity center -size ${width}x15 \
                -font Verdana -pointsize 10 \
                caption:"Copyright © 2007 Pario.no" \
                +size $base +swap -gravity south -composite $I/$base;

                # delete resized file
                rm $base
        done

        # Delete source file (DO NOT USE YOUR ORIGINAL FILE!)
        rm $IMAGEFILE
done

You can download my resize, watermark bash script here.