On Monday 29 Jun 2015 16:34:16 hw wrote:
> Am 24.06.2015 um 07:35 schrieb Mick:
> > On Wednesday 24 Jun 2015 01:02:35 [email protected] wrote:
> >> hw <[email protected]> wrote:
> >>> Hi,
> >>> 
> >>> suppose I have a number of images that need to be displayed side by
> >>> side in a nice layout.  The images are of different sizes and have
> >>> different aspect ratios.
> >>> 
> >>> To fit the images into the layout, I can scale the images either by
> >>> height or width or by percantage, and they will look messy in the
> >>> layout because I need to keep their aspect ratio when scaling them.
> >>> 
> >>> So what I need to do is put a frame around each image just as needed
> >>> when scaling it so that I will end up with all the images having the
> >>> same size while maintaining their aspect ratio.
> >>> 
> >>> I guess 'convert' (from imagemagick) or 'ffmpeg' can do this, yet I
> >>> couldn't find out how.
> >>> 
> >>> 
> >>> (In this particular case, I would set a default size to scale all
> >>> images to rather than doing something more complicated like examine
> >>> all images in advance to compute a good size to use from the largest
> >>> or smallest one or from their average dimensions.)
> >>> 
> >>> 
> >>> Any ideas how to do this?
> >> 
> >> Look here:
> >> 
> >> http://stackoverflow.com/questions/1787356/use-imagemagick-to-place-an-i
> >> mag e-inside-a-larger-canvas
> >> 
> >> You must add a resize paremeter as this example is only for placing an
> >> image inside a larger canvas. :-)
> >> 
> >> You can easily find more examples in the Internet.
> >> 
> >> --
> >> Regards
> >> wabe
> > 
> > Give this a spin, or modify accordingly to suit your needs:
> > 
> > ============================================
> > #!/bin/bash
> > for i in *.JPG; do
> > 
> >    name=${i%.JPG}
> >    convert -resize 900x675 ${i} ${name}_s.jpg
> > 
> > done
> > ============================================
> 
> This doesn't add a frame to keep the aspect ratio, or does it?


No, the above example will resize it to the dimensions you give it.


You can however define the '-geometry' instead and do it in many different 
ways so as to preserve the aspect ratio.  For example if you only give it '-
geometry width', then the hight will be automatically adjusted to preserve the 
current aspect ratio.  If you only give '-geometry xheight' then the width 
will be auto-adjusted to retain the aspect ratio.

You can also use scale% as a geometry parameter to increase the image by a 
particular percentage.  Have a look at:

file:///usr/share/doc/imagemagick-6.9.0.3/html/www/command-line-
processing.html#geometry

(depending on your version of imagemagick) for more information.

-- 
Regards,
Mick

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to