[Digikam-users] how to resize image to a new and smaller formate -

Jean-François Rabasse jean-francois.rabasse at wanadoo.fr
Mon Apr 9 12:54:00 BST 2012



Hello all,

Some comments about these images resizing issues.
(And I am another user of the ImageMagick convert program, a really powerful
tool with dozens of options.)

First I'd like to point out a syntax detail that may be - in my opinion -
questionable in some occasions. Examples shown were :
     convert <source-image> -resize 800x600 <target-image>

This syntax, -resize 800x600, will produce a final image with 800 pixels
width and 600 pixels height, and this may be inappropriate when the original
image hasn't the same aspect ratio. 800x600 is a 4:3 aspect ratio and many
cameras produce 3:2 aspect ratio images. More, if the original image is in
portrait orientation, 800x600 will produce a landscape orientation,
with severe image distortions.

The convert program can resize using a bounding box mechanism.
     convert <source-image> -resize '800x800>' <target-image>

(The size argument must be enclosed in single quotes because of the presence
of the '>' character that may upset the shell, for it's output redirection.)

With that syntax, whatever the original image dimensions are, whatever the
aspect ration is, 4:3, 3:2, other, and whatever the orientation is, portrait
or landscape, the final result will fit into a 800x800 square, the largest
dimension being scaled to 800 and the other dimension recomputed by convert
to maintain the original aspect ratio. Seems to be more flexible than
specifying width and height, and it prevents any kind of distortion.



As for the question :

> I don't understand why you would use a script as Digikam appears to bring
> almost everything in a user-friendly UI. Can you explain why you would
> rather go for the 'complicate' way.

Well, as I said above, I'm a IM convert user. I can't speak for other users,
of course, but I could say exactly the same things Remco said a little
earlier, i.e. « I use shell scripts... in combination with other actions
that Digikam cannot do » , « there are things that are just easier to do
that way » , « shell scripts can be stored » , etc.

I don't consider this to be the complicated way, but the flexible way
(at least for user that are used to shell scripting).
Some examples ?

1. I usually build three different versions of images (for web usage).
     - a standard size for web pages, e.g. -resize '600x600>'
     - a larger size (when implementing functions such as « Click to
     enlarge » and link to a larger version), e.g. -resize '1280x1280>'...
     - a very small size for thumbnails, e.g. -resize '96x96>'...

     So I need three sets of dimensions for each source image, and a shell
     loop is really convenient, provided output names be also rebuilt,
     XXX.jpg -> XXX.jpg, XXX-large.jpg, XXX-small.jpg
     Using a GUI based batch system would require to replay the whole
     processing three times, one for each dimensions set.

2. I tune outputs with different quality factors / image compression,
     using another convert option. E.g. convert ... -quality 96 for large
     images, but for smaller images or icons, -quality 75 is Ok. And this
     spares hosting disk space and uploading/downloading time.

3. I always remove all metadata informations from final images, convert
     has a -strip option.

4. I always build progressive JPEG using : convert... -interlace plane
     because I consider this is more pleasant for visitors having a low
     or medium speed ADSL connection.

5. I sometime do some decorations with -frame... options, or label
     images, etc.

6. Last, ImageMagick provides other tools than the convert program.
    I sometime use the 'montage' program to build special things such as
    icons images built from two pictures (twin mode).
    And all this can be easily made scriptable.

And keeping different shell scripts under hand, ready to be run on demand
is, from my point of view, really flexible.
But, as always, it's nothing but a matter of taste. :)

Regards,
Jean-François


More information about the Digikam-users mailing list