views:

121

answers:

1

I have a folder of about 20000 images, and I need to generate thumb images for them.

What's the fastest way to do this job?

I know I can do it using some image resizing libraries. But I am wondering maybe there's already a tool or code snippets that could do this job.

+6  A: 

imagemagick convert tool. It's a command line tool that works well both in Linux and Windows.

for converting a single image:

convert dragon.gif    -resize 50%  half_dragon.gif

Or, if you prefer thumbnails with a fixed size (here, 4096 pixels):

convert dragon.gif    -resize 4096@  pixel_dragon.gif

Or the most common use - resize into a given size:

convert dragon.gif    -resize 64x64  resize_dragon.gif

And for a large amount of image, quick-resize is available:

The resize operator can also be applied to images immediately after being read, before it is added to the current image sequence and the next image is read.

So,

convert dragon.gif'[64x64]'    read_dragon.gif

Is probably the correct answer to your question.

These examples are taken from the resize section of the imagemagick.org site; you can find numerous other examples there.

for converting a while library of images, you can write a small shell script, like:

for file in `ls`;
do
    convert $file  -resize 4096@ thumb_$file
done

For a very large amount of files, you might want to use Linux's find -exec to overcome the very long argument list which ls would yield.

Adam Matan
why somebody downvotes this? at least i don't need to know any libraries. what i need is to generate a long .bat file:-|but can 50% be changed to a absolute size?
David
Yes, use the '@' sign to determine the amount of pixels. I think you don't have to write a very long batch file - just a small loop which would iterate every file.
Adam Matan
I'd like to write 8 .bat files and run them together to get some parallel. :)
David