1 |
On Monday 29 Jun 2015 16:34:16 hw wrote: |
2 |
> Am 24.06.2015 um 07:35 schrieb Mick: |
3 |
> > On Wednesday 24 Jun 2015 01:02:35 wabenbau@×××××.com wrote: |
4 |
> >> hw <hw@×××××××××××××××××××××.de> wrote: |
5 |
> >>> Hi, |
6 |
> >>> |
7 |
> >>> suppose I have a number of images that need to be displayed side by |
8 |
> >>> side in a nice layout. The images are of different sizes and have |
9 |
> >>> different aspect ratios. |
10 |
> >>> |
11 |
> >>> To fit the images into the layout, I can scale the images either by |
12 |
> >>> height or width or by percantage, and they will look messy in the |
13 |
> >>> layout because I need to keep their aspect ratio when scaling them. |
14 |
> >>> |
15 |
> >>> So what I need to do is put a frame around each image just as needed |
16 |
> >>> when scaling it so that I will end up with all the images having the |
17 |
> >>> same size while maintaining their aspect ratio. |
18 |
> >>> |
19 |
> >>> I guess 'convert' (from imagemagick) or 'ffmpeg' can do this, yet I |
20 |
> >>> couldn't find out how. |
21 |
> >>> |
22 |
> >>> |
23 |
> >>> (In this particular case, I would set a default size to scale all |
24 |
> >>> images to rather than doing something more complicated like examine |
25 |
> >>> all images in advance to compute a good size to use from the largest |
26 |
> >>> or smallest one or from their average dimensions.) |
27 |
> >>> |
28 |
> >>> |
29 |
> >>> Any ideas how to do this? |
30 |
> >> |
31 |
> >> Look here: |
32 |
> >> |
33 |
> >> http://stackoverflow.com/questions/1787356/use-imagemagick-to-place-an-i |
34 |
> >> mag e-inside-a-larger-canvas |
35 |
> >> |
36 |
> >> You must add a resize paremeter as this example is only for placing an |
37 |
> >> image inside a larger canvas. :-) |
38 |
> >> |
39 |
> >> You can easily find more examples in the Internet. |
40 |
> >> |
41 |
> >> -- |
42 |
> >> Regards |
43 |
> >> wabe |
44 |
> > |
45 |
> > Give this a spin, or modify accordingly to suit your needs: |
46 |
> > |
47 |
> > ============================================ |
48 |
> > #!/bin/bash |
49 |
> > for i in *.JPG; do |
50 |
> > |
51 |
> > name=${i%.JPG} |
52 |
> > convert -resize 900x675 ${i} ${name}_s.jpg |
53 |
> > |
54 |
> > done |
55 |
> > ============================================ |
56 |
> |
57 |
> This doesn't add a frame to keep the aspect ratio, or does it? |
58 |
|
59 |
|
60 |
No, the above example will resize it to the dimensions you give it. |
61 |
|
62 |
|
63 |
You can however define the '-geometry' instead and do it in many different |
64 |
ways so as to preserve the aspect ratio. For example if you only give it '- |
65 |
geometry width', then the hight will be automatically adjusted to preserve the |
66 |
current aspect ratio. If you only give '-geometry xheight' then the width |
67 |
will be auto-adjusted to retain the aspect ratio. |
68 |
|
69 |
You can also use scale% as a geometry parameter to increase the image by a |
70 |
particular percentage. Have a look at: |
71 |
|
72 |
file:///usr/share/doc/imagemagick-6.9.0.3/html/www/command-line- |
73 |
processing.html#geometry |
74 |
|
75 |
(depending on your version of imagemagick) for more information. |
76 |
|
77 |
-- |
78 |
Regards, |
79 |
Mick |