Creating multiple thumbnails without re-reading original

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
mef
Posts: 1
Joined: 2011-07-05T07:32:27-07:00
Authentication code: 8675308

Creating multiple thumbnails without re-reading original

Post by mef »

I'm trying to create multiple thumbnails of different dimensions from an original without re-reading the original each time, in a single convert command.

The command that seems to work best is:

Code: Select all

convert 'original.jpg' -write mpr:orig +delete \
mpr:orig -resize 'x150>' -write '150.jpg' +delete \
mpr:orig -resize 'x400>' -write '400.jpg' +delete \
mpr:orig -resize '900>' '900.jpg'
I'm wondering if there's a better way?

I've tried +clone, which seems to be slightly slower than mpr:

Code: Select all

convert 'original.jpg'  \
\( +clone -resize 'x150>' -write '150.jpg' \) -delete 1 \
\( +clone -resize 'x400>' -write '400.jpg' \) -delete 1 \
-resize '900>' '900.jpg'
And I've also tried +write, but it seems that each thumbnail uses the output of the previous thumbnail instead of the original. In this code, the 900> thumbnail will be the same as the x150> thumbnail.

Code: Select all

convert 'original.jpg' -resize 'x150>' +write '150.jpg' \
-resize '900>' +write '900.jpg' \
-resize 'x400>' '400.jpg'
Any tips would be appreciated. Thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating multiple thumbnails without re-reading original

Post by fmw42 »

I would expect your mpr approach to be the best and fastest as mpr is in-memory.
Post Reply