Shell Scripts

Multiple Images Bounding Box

#!/bin/bash
# calculates the bounding box of a set of images given by their filename
# needs ImageMagick installed on your system (already installed in Ubuntu, download at http://www.imagemagick.org/script/index.php).
# example usage : ls *.jpg | boundingbox, example output: "424 448"
dimensions=$(xargs identify | cut -d " " -f3 | tr 'x'  ' ');
# the " signs are important because without them bash removes the newlines
max_width=$( echo "$dimensions" | cut -f1 -d " " | sort -n -r | head -1)
max_height=$(echo "$dimensions" | cut -f2 -d " " | sort -n -r | head -1)
echo "$max_width" "$max_height"