Collage with individual sizes and pos. from the same image

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
cooper64
Posts: 2
Joined: 2012-04-10T00:44:28-07:00
Authentication code: 8675308

Collage with individual sizes and pos. from the same image

Post by cooper64 »

Hallo,

what I have is one source image and 3x geometry data to position the image three times on different places and sizes in a white background. Target image should have a size of 500x500px.
Example geometry data:
167x251+166+25
126x187+124+292
249x292+126+187

What I need is that:
Image

Is it possible to create that in one command-line? Or it is only possible to realize that with multiple commands? (I am interested in a minimum of calculation time)
I think, montage in combination with -tile is not working for me.

Additional rotate question:

Is it also possible in the same step, to rotate some of the pictures?
Like this:
Image

I need your help, in the tutorials i've not found a solution.
Thanks.

cooper64

cooper
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Collage with individual sizes and pos. from the same ima

Post by fmw42 »

please provide a clean separate copy of your input image. then I think we can give you the command(s)

or see

http://www.imagemagick.org/Usage/layers/#flatten

and use parenthesis processing with clones to shrink and/or rotate your image

see

http://www.imagemagick.org/Usage/basics/#parenthesis
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Collage with individual sizes and pos. from the same ima

Post by anthony »

It is straight forward.

Code: Select all

   convert  {image} -rotate -90\> -background white -gravity center \
                \( +clone -resize 50% 
                   -duplicate 1 +append \) \
                -append   {result}
the -rotate -90\> ensures the image is in landscape

Here is your second request...

Code: Select all

   convert  {image} -rotate -90\> -background white -gravity center \
                \( +clone -resize 50% \
                   \( +clone -resize 50% -rotate -90 \
                     -duplicate 1 -append \) \
                   +append \) \
                -append   {result}
Can you see the expansion of the code? Follow that and you can make N images each hafl the size of the other.

If you are on windows, see Windows DOS scripting
http://www.imagemagick.org/Usage/windows/#dos
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Collage with individual sizes and pos. from the same ima

Post by anthony »

If you want the images to fit to printed paper. Then the image should be padded out to a specific ratio.
That is is size is a ratio of 1:sqrt(2)

The metric paper system uses that system
A0 = 1 square meter in this ratio 841mm X 1189mm
half A0 => A1 whcih also has the same ratio
half A1 => A2
etc until you get the popular sizes A4 and A5

By that logic A4 is 1/(2^4) or 1/16 meters square.
This is the size you will probbaly be wanting to re-create as that is printing sizes.

So the next question... How to pad out an image to this ratio?
(or better still to any specified ratio?)

Of course the -resize in this arrangement is NOT 50%.... but needs to be resize by the same ratio.
That is 1/sqrt(2) or -resize 70.71% which with rotation should allow two images to fit exactly against, or even into the larger image.

So if your initial image is A5 in size. the next two 70.71% smaller image appeneded to one size will produce a A4 printing page.
Or you can fit on a A4 page: a 1 x A5, and 2 x A6 images, or an A5, A6 and 2 A7 images ;-)
that is the beauty of the metric paper system
http://en.wikipedia.org/wiki/ISO_216
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Collage with individual sizes and pos. from the same ima

Post by anthony »

Taking this further.

If your original figure has a aspect ratio of W:H
And you want two rotated images to fit the longer size (say 'W')
You can make use of the bounding box argument of resize, in which case
rotate the image 90 degrees, and resize it to fit a (W/2)x(W/2) pixel box.

Assuming the W dimention is a multiple of 2,
unless you want to get into sub-pixel resizing using distorts :-) Which is not recommended for this!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Collage with individual sizes and pos. from the same ima

Post by anthony »

I wish to point out, as it was pointed out to me (Thanks Fred)
1:sqrt(2) is not a golden ratio. It is the Lichtenberg Ratio
I really should read my own references more fully :-)
I'll fix my previous posts.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Collage with individual sizes and pos. from the same ima

Post by fmw42 »

anthony wrote:It is the Lichtenberg Ratio
Interesting, I had never heard of that one. Looking it up. see http://en.wikipedia.org/wiki/Lichtenberg_ratio#History
cooper64
Posts: 2
Joined: 2012-04-10T00:44:28-07:00
Authentication code: 8675308

Re: Collage with individual sizes and pos. from the same ima

Post by cooper64 »

Thank you for your support.

My image sizes are not always 50% of the source image. Rather, they are different combinations of photo standard formats - like (13x18, 9x13, 6x9, or passport photo).
But the displayed result image must not be exact in the proportions.

So I think your command example will work for me, I will try it.

Yet once again my question: Would it also work with the specification of coordinates? (like {image} -geometry 195x284+163+18 ( +clone -resize 50% -geometry 107x155+149+305...)

The background is:
The user wants to create their own combinations of image sets. I can explain to him the using of coordinates, but not the using of ImageMagick commands :)

And a small question to your example: Is it possible to set the white background to a fix size (e.g. 500x500px)?

Thanks for your support. I work for the first time a little more intense with ImageMagick. It's really amazing what this tool can realize!

cooper
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Collage with individual sizes and pos. from the same ima

Post by anthony »

Do not use a size in the -geometry option
The geometry offset is used later in a low level -composition. which you don't seem to use.

An alturnative is to set a 'page' or 'virtual canvas' offset. This us used for 'layering' images.

For example of may different ways of 'laying out' images in a completely user controled way, see
IM examples, Layering Multiple Images
http://www.imagemagick.org/Usage/layers/

It starts with append, works though multiple two image compose methods, to multi-image layering methods and finally finishes up with programmed layout methods.

More formal layout methods are planned for late IMv7 development.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply