Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top