home | list info | list archive | date index | thread index

Re: [OCLUG-Tech] find images by size

On Thu, Jul 26, 2007 at 14:11:17 -0400, Bruce Harding wrote:
> On Tuesday 24 July 2007 11:06 pm, Michael P. Soulier wrote:
> > On 24/07/07 Bruce Harding said:
> > > So can some one help me out with a command/script/regex to find, mv, and
> > > the convert these images which are to large? The too large images are all
> > > large than 160 dpi, but of various sizes.
> >
> > Can you identify them by running "identify" on each file and keying off of
> > the output, which includes the image size?
> >
> > Mike
> 
> Someone sent me this from another group. 
> 
> identify -format '%f: %wx%h\n' * | grep '[02-9][0-9][0-9]\|1[5-9][0-9]' | 
> cut -d ' ' -f 1
 
I don't think that does what you want.  Something like the following
will process only those images with resolution greater than 160 dpi.

MAX=160
identify -format '%x %y %f\n' *.jpg *.gif |
while read X Units Y Units File; do
  [ "$X" ] || break  # Discard extra newline at eof.
  if [ $X -gt $MAX -o $Y -gt $MAX ]; then
    ...
    mogrify -scale x160 "$File"
    mv ...
    ...
    fi
  done

I'm not quite sure what else you are trying to do.

Joe