Diagonally collage images

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
Don
Posts: 47
Joined: 2013-05-09T14:10:43-07:00
Authentication code: 6789

Diagonally collage images

Post by Don »

Hello,

I was wondering if it is possible to create the collage effect below with imagemagick? (Please see link)

https://picasaweb.google.com/lh/photo/x ... directlink

Much appreciated, thank you!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Diagonally collage images

Post by fmw42 »

It is just a normal rectangular collage that has been rotated and boundaries drawn.

Here is an example made from one image (though a variation could use multiple images).

input:
Image

Code: Select all

convert coke_can2.jpg \
\( -clone 0 -gravity north -crop 100x50+0+0% +repage -background white -gravity south -splice 0x10 \) \
\( -clone 0 -gravity west -crop 50x50+0+0% +repage -gravity east -chop 5x0 -background white -splice 5x0 \) \
\( -clone 0 -gravity west -crop 50x50+0+0% +repage -gravity west -chop 5x0 -background white -splice 5x0 \) \
\( -clone 2 -clone 3 +append \) \
-delete 0,2,3 -append \
-background white -rotate -5 +repage \
-gravity center -crop 80%x80%+0+0 +repage \
-bordercolor white -border 10 coke_can2_collage.jpg
Image
Don
Posts: 47
Joined: 2013-05-09T14:10:43-07:00
Authentication code: 6789

Re: Diagonally collage images

Post by Don »

That's great thanks!

I was trying to do it with 3 different images using/modifying the code you gave me but no avail, can you pls guide me in the direction in trying to do it with multiple different images?

As always, much appreciated!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Diagonally collage images

Post by fmw42 »

Post the 3 images to some place like dropbox.com (public folder) and put the URL(s) here, so I can see your image and try to modify the code.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Diagonally collage images

Post by fmw42 »

Also please explain how you are deciding how much of each image to put together if not the whole image. The bottom two must be half the width of the top one or they need to be resized and or cropped.
Don
Posts: 47
Joined: 2013-05-09T14:10:43-07:00
Authentication code: 6789

Re: Diagonally collage images

Post by Don »

Hello Fred,

Here are the 3 images: (I uploaded to my picasaweb album; should take you directly to the image for you to save to your computer; right click Save-As over image)

First image: https://picasaweb.google.com/lh/photo/B ... directlink
This image is to be across, on the top.

Second image: https://picasaweb.google.com/lh/photo/I ... directlink
This image on the bottom, left or right side.(which ever side is fine)

Third image: https://picasaweb.google.com/lh/photo/d ... directlink
This image on the bottom, left or right side.(which ever side is fine)

I would like the overall collage size (image size) to be 800 pixels. (At least). The images should be resized and cropped to fit within this 800 width collage(image). So perhaps, the bottom two images are resized and cropped to width of 400 pixels each. The top image is resized/cropped to be about the total width of the collage; 800px.

I greatly appreciate your assistance. Thank you!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Diagonally collage images

Post by fmw42 »

It is getting late here. I will work on it tomorrow afternoon/evening and get back to you.

What version of IM and platform are you using?
Don
Posts: 47
Joined: 2013-05-09T14:10:43-07:00
Authentication code: 6789

Re: Diagonally collage images

Post by Don »

No problem of course. Appreciate it. :)

IM version: ImageMagick 6.8.9-1 Q16 x86_64 2014-06-28
Platform: Mac OS X
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Diagonally collage images

Post by fmw42 »

try these two variations. In the second one you have to pick the gravity for cropping the top image into a half height image (or replace -gravity with -geometry +0+Y to shift the half size to some arbitrary position)

Code: Select all

infile1="IMG_8687.jpg"
infile2="batmanboy.jpg"
infile3="squirrel.jpg"
convert \
\( "$infile1" -resize 800x -gravity north -crop 800x800+0+0 +repage -background white -gravity south -splice 0x10 \) \
\( "$infile2" -resize 400x400^ -gravity center -crop 400x400+0+0 +repage -gravity east -chop 5x0 -background white -splice 5x0 \) \
\( "$infile3" -resize 400x400^ -gravity center -crop 400x400+0+0 +repage -gravity west -chop 5x0 -background white -splice 5x0 \) \
\( -clone 1 -clone 2 +append \) \
-delete 1,2 -append \
-background white -rotate -5 +repage \
-gravity center -crop 80%x80%+0+0 +repage \
-bordercolor white -border 10 result1.jpg
Image

Code: Select all

infile1="IMG_8687.jpg"
infile2="batmanboy.jpg"
infile3="squirrel.jpg"
topgravity="south"
convert \
\( "$infile1" -resize 800x -gravity $topgravity -crop 800x400+0+0 +repage -background white -gravity south -splice 0x10 \) \
\( "$infile2" -resize 400x400^ -gravity center -crop 400x400+0+0 +repage -gravity east -chop 5x0 -background white -splice 5x0 \) \
\( "$infile3" -resize 400x400^ -gravity center -crop 400x400+0+0 +repage -gravity west -chop 5x0 -background white -splice 5x0 \) \
\( -clone 1 -clone 2 +append \) \
-delete 1,2 -append \
-background white -rotate -5 +repage \
-gravity center -crop 80%x80%+0+0 +repage \
-bordercolor white -border 10 result2.jpg
Image
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Diagonally collage images

Post by Bonzo »

Looks like that squirrel has been eating to many nuts.
Don
Posts: 47
Joined: 2013-05-09T14:10:43-07:00
Authentication code: 6789

Re: Diagonally collage images

Post by Don »

Thank you Fred for your assistance! You have led me in the right direction! :)

Bonzo, yes, too many nuts for that squirrel. :) By the way, great imagemagick site! Great reference, examples!
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Diagonally collage images

Post by Bonzo »

Thanks for the comment about my website Don.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Diagonally collage images

Post by fmw42 »

I have added a new script, diagcollage, to do this effect. It is available at my web site at the link below.
rossdv8
Posts: 47
Joined: 2014-03-12T21:54:20-07:00
Authentication code: 6789

Re: Diagonally collage images

Post by rossdv8 »

fmw42 wrote:I have added a new script, diagcollage, to do this effect. It is available at my web site at the link below.
Damn! I spent weeks writing a script to achieve this https://dl.dropboxusercontent.com/u/576 ... mposed.jpg using ImageMagick.

I could have just gone to Fred's web site and saved myself the hassle :-(

I'm going to have a look anyway because I bet Fred's solution is much more elegant than mine.
rossdv8
Posts: 47
Joined: 2014-03-12T21:54:20-07:00
Authentication code: 6789

Re: Diagonally collage images

Post by rossdv8 »

Hmm, Fred's script is a lot simpler than mine and does a few things I have not worked out how to do yet.

And Fred's is a true self contained script, where mine relies on dropping four images into a folder then starting the script. Then the script moves each of the images to various folders to process. I made the shapes for each section and crop each image to its shape before stitching them together to form the collage.
And I don't want my images rotated, and I also enhance the colours at the end after text is added.

I can see I have a lot to learn about this yet :-) But it was interesting to see that someone else wanted to make a collage that is similar to an Android PhotoGrid.

It always surprises me how simple Fred, Anthony and Snibgo make all this look.
But what frustrates me is that I spend weeks coming up with a way to do this - and these blokes do it overnight !!
Post Reply