#!/bin/bash

LIMIT_W=300
LIMIT_H=300

find . -name '*.jpg' -o -name '*.png' -o -name '*.jpeg' | while read FILE; do
	BASENAME=$(basename "$FILE")
	IDENTIFY=$(identify "$BASENAME")

	[[ "$IDENTIFY" =~ ([0-9]+)+x([0-9]+) ]]

	if [ "${BASH_REMATCH[1]}" -lt "$LIMIT_W" ] && [ "${BASH_REMATCH[2]}" -lt "$LIMIT_H" ]; then
		echo "Removing: $FILE"

		rm "$FILE"
	fi
done