[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: making thumbnails



Steve Greig wrote:
> I have about 60 large jpg files in a directory. They are almost all over
> 2MB in size. I want to put them on the internet but wanted to make a
> thumbnail version and a small version (about 75KB) of each one so the web
> page does not take too long to load.

Off the top of my head I would do something like this.  Use whatever
thumbnail size you prefer.

  thumbsize=100x100
  for f in *.jpg; do
    echo convert -size $thumbsize -resize $thumbsize $f $thumbsize.$f
  done

If you use upper case .JPG instead then adjust accordingly.  Test with
the above.  After testing and the result is what you want then remove
the 'echo' and do it for real.

I showed the above as separate lines thinking it was more
understandable that way for the email.  But being something I would do
on the command line I would usually simply type it in all at one time
as a one-liner.

  thumbsize=100x100; for f in *.jpg; do echo convert -size $thumbsize -resize $thumbsize $f $thumbsize.$f; done

Also you probably have your own preferences for naming.  Instead of
$thumbsize.$f which would produce names such as 100x100.IM004400.jpg
you can use whatever format you wish there.

It is also okay to avoid some of the variables and just have the size
listed out.

  for f in *.jpg; do echo convert -size 100x100 -resize 100x100 $f 100x100.$f; done

The -resize is the option that does the work.  But you said these are
large images.  It is a little more efficient if the tool knows the
final size.  Hinting with -size helps it run more efficiently since
that is the final size.  (Found that in the ImageMagick docs years
ago.  Actually not sure if that is still a recommended hint or not.)

Just ideas for you...

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: