Fastest way of scaling an image (thumbnail generation)

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
tomf

Fastest way of scaling an image (thumbnail generation)

Post by tomf »

Whats the fastest way of scaling an image? Most images are jpgs, and I don't really care about the quality. It should just be fast.

I tried:

Code: Select all

convert image.jpg -size 256x256 -thumbnail 256x256 output.jpg
but it's much slower (10 times) than for example irfanview. It looks better - yes - but I don't need the quality.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Fastest way of scaling an image (thumbnail generation)

Post by magick »

Put the -size option before your image filename.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Fastest way of scaling an image (thumbnail generation)

Post by fmw42 »

Also if you use png for the output then jpg compression does not slow things down. The file sizes will be larger. So I am not sure which will be slower, doing the jpg compression or the larger size file writing. You may want to test this and get back to the forum with what you find. I think we would all be interested. Unless someone already knows.
tomf

Re: Fastest way of scaling an image (thumbnail generation)

Post by tomf »

jpg ist faster:

Code: Select all

===  convert -size 256x256 1.jpg -thumbnail 256x256 thumbs/1.jpg ===

Execution time: 0.375 s

Code: Select all

===  convert -size 256x256 1.jpg -thumbnail 256x256 thumbs/1.png ===

Execution time: 0.506 s
The -size argument before the filename makes it faster but not fast enough. Can't I use a simpler scaling-filter?

Here is a picture taken from irfanviews batch conversion:
Image
And here from imagemagick (the quality is better which I don't need)
Image
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Fastest way of scaling an image (thumbnail generation)

Post by magick »

Next up, use -sample instead of -thumbnail.
Post Reply