Crop all Pictures in Folder with ImageMagick

Using bash and ImageMagick we can crop all the pictures in a folder in a single shoot:

fix='crop'
it=1
for file in $2/*; 
do
    if [[ -f $file ]]; 
    then
        output=$2/${fix}${it}.png
        echo "$file --> $output"
        convert -crop $1 "$file" "$output"
        it=$((it+1))
    fi
done

The script, called crop.sh is run as:

./crop.sh 525x240+675+150 ~/Pictures/

The first argument is the argument for the ImageMagick’s crop tool and the second argumen is the folder where the pictures to be cropped are.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: