How to detect image size?

gb spam gbofspam at gmail.com
Mon Sep 19 22:35:18 UTC 2005


On 9/19/05, Strong <s-strong at mail.ru> wrote:
> I have a huge of imges (jpg, bmp, gif) in a huge dirs/subdirs. I want to
> remove those whose height/width is less, say 500 pixels. I looked at
> ImageMagic programs but didn't find one that offers such info. I suppose
> it should be one-two-line bash script. Does anyone knows how to do that?

identify (from image magik) gives the dimensions, you just need to do
a few gynastics to get the output in a form that is useful.

adjust the follow to suit your needs:

find . -name '*.jpg' | xargs -l1 identify -ping | awk '{FILE=$1;
sub("[[].*", "", FILE); X=$3; sub("x.*", "", X); Y=$3; sub(".*x", "",
Y); if ((X<500) || (Y<500)) printf("%s : %ix%i\n", FILE, X, Y)}'




More information about the fedora-list mailing list