Following up from my last post about grabbing images from a squid cache, I needed a better way to remove thumbnails than just looking at file sizes.
I decided to try and get the image dimensions and then look at the mean width/height value.
This was what I came up with:-
#!/bin/bash
for file in *; do
size=$(identify -format "%w %h" "$file")
w=$(echo $size | cut -f 1 -d " ")
h=$(echo $size | cut -f 2 -d " ")
mean=$(( ($h + $w)/2 ))
if (( mean < 300 )); then
echo "$file $h $w $mean"
rm "$file"
fi
done
You will need the excellent ImageMagick package, which is available in most distros.
