#!/bin/bash
for image in ../*/*.{jpg,png}
do
	width="$(identify -ping -format '%w' "$image")"
	if ((width > 320))
	then
		origimage="original/${image#../}"
		origdir="${origimage%/*}"
		if [ ! -d "$origdir" ]
		then
			mkdir "$origdir"
		fi
		if [ ! -f "$origimage" ]
		then
			cp "$image" "$origimage"
		fi
		echo "$image $width"
	fi
done
