Page 1 of 2
Overlaying a picture on a collage/montage (with mogrify)
Posted: 2008-04-24T08:46:49-07:00
by qvack
Hello. I've been trying to figure this out on a few occasions, and after hours of documentation reading the closest I've come to doing what I want is "mogrify -draw 'image Over 0,0 0,0 overlay.jpg' image.jpg", which really isn't... good enough.
So, now I'm kindly asking for your help, magicians? :p
Basically what I want is a "watermark" of sorts in NorthWest, Center (?) and SouthEast of the montage.... I'll let a crude example I made with The Gimp illustrate:

Re: Overlaying a picture on a collage/montage (with mogrify)
Posted: 2008-04-24T10:36:09-07:00
by Bonzo
I would use convert as composite only works with 2 images:
Code: Select all
composite -gravity center logo.jpeg foto.jpg output.jpg
Code: Select all
convert main_image.jpg first_logo.jpg -gravity northwest -composite second_logo.jpg -gravity center -composite third_logo.jpg -gravity southeast -composite output.jpg
Re: Overlaying a picture on a collage/montage (with mogrify)
Posted: 2008-04-26T09:23:33-07:00
by qvack
thank you. worked like a charm.

Re: Overlaying a picture on a collage/montage (with mogrify)
Posted: 2010-01-22T02:05:25-07:00
by ShekarKCB
Hi,
I have similar requirement. I need to collage 5-10 images to single image, I used below code
Code: Select all
convert image-0.jpg image-2.jpg image-3.jpg -gravity northwest -composite image-0.jpg -gravity center -composite image-2.jpg -gravity southeast -composite image-3.jpg -resize 320x240! output.jp
But it is not generating image with 320x240 and collage of images, instead it is generating output-0.jpg and output-1.jpg , Please assist.
Generally any no of image comes (say min 2 to max 9) i should be able to create a collage with convert option.
Thanks,
ShekarKCB
Re: Overlaying a picture on a collage/montage (with mogrify)
Posted: 2010-01-22T10:41:36-07:00
by fmw42
convert ... composite only processed two images at a time (a third can be a mask)
http://www.imagemagick.org/Usage/compose/#compose
convert image1 image2 -gravity ... -composite image3 -gravity ... -composite image4 -gravity ... -composite .... result
Re: Overlaying a picture on a collage/montage (with mogrify)
Posted: 2010-01-22T11:15:38-07:00
by Bonzo
You may want to look at -append;
http://www.imagemagick.org/script/comma ... php#append You can create your rows then join the rows together.
How are you running your code as you may be able to use a batch file, or php etc.
http://www.rubblewebs.co.uk/imagemagick ... mple_b.php

Re: Overlaying a picture on a collage/montage (with mogrify)
Posted: 2010-02-23T03:34:48-07:00
by Chandrashekar Bhat
Hi,
I have about 9 images say from image-0 to image-1. (of dimension 320x240) , Since i need 9x9,
First i am creating i-0 to i-1.jpg using below mentioned code.
Code: Select all
convert image-0.jpg -resize 105x107 -quality 100 i0.jpg;
convert -border 14x14 -bordercolor white -quality 100 i0.jpg i_0.jpg;
convert image-1.jpg -resize 105x107 -quality 100 i1.jpg;
convert -border 14x14 -bordercolor white -quality 100 i1.jpg i_1.jpg;
convert image-2.jpg -resize 105x107 -quality 100 i2.jpg;
convert -border 14x14 -bordercolor white -quality 100 i2.jpg i_2.jpg;
convert image-3.jpg -resize 105x107 -quality 100 i3.jpg;
convert -border 14x14 -bordercolor white -quality 100 i3.jpg i_3.jpg;
convert image-4.jpg -resize 105x107 -quality 100 i4.jpg;
convert -border 14x14 -bordercolor white -quality 100 i4.jpg i_4.jpg;
convert image-5.jpg -resize 105x107 -quality 100 i5.jpg;
convert -border 14x14 -bordercolor white -quality 100 i5.jpg i_5.jpg;
convert image-6.jpg -resize 105x107 -quality 100 i6.jpg;
convert -border 14x14 -bordercolor white -quality 100 i6.jpg i_6.jpg;
convert image-7.jpg -resize 105x107 -quality 100 i7.jpg;
convert -border 14x14 -bordercolor white -quality 100 i7.jpg i_7.jpg;
convert image-8.jpg -resize 105x107 -quality 100 i8.jpg;
convert -border 14x14 -bordercolor white -quality 100 i8.jpg i_8.jpg;
Then trying to create a collage using this command
Code: Select all
convert -size 310x340 xc:#262b38 i_0.jpg -geometry +0+0 -composite i_1.jpg -geometry +105+0 -composite i_2.jpg -geometry +210+0 -composite i_3.jpg -geometry +0+107 -composite i_4.jpg -geometry +105+107 -composite i_5.jpg -geometry +210+107 -composite i_6.jpg -geometry +0+214 -composite i_7.jpg -geometry +105+214 -composite i_8.jpg -geometry +210+214 -composite -trim combined.jpg;
Finally adding the border
Code: Select all
convert -border 3x0 -bordercolor white -quality 100 combined.jpg New_Approach.jpg;
I am able to get the collage, but border is not proper. i.e Since each image will have 14x14 (all the four sides, it will clash up with the next image. Is there any way where i can add border to only one side (top or right or left or bottom)?.
Or is there any better way to create a collage ? pls help...
Thanks
ShekarKCB
Re: Overlaying a picture on a collage/montage (with mogrify)
Posted: 2010-02-23T03:43:22-07:00
by Bonzo
Try -splice:
Code: Select all
convert image-0.jpg -background White -gravity south -splice 0x20+0+0
Out of interest after version 6 you should read the image in first then use the operators:
Code: Select all
Wrong
convert -border 14x14 -bordercolor white -quality 100 i0.jpg i_0.jpg;
Correct
convert i0.jpg -border 14x14 -bordercolor white -quality 100 i_0.jpg;
Re: Overlaying a picture on a collage/montage (with mogrify)
Posted: 2010-02-23T22:43:21-07:00
by Chandrashekar Bhat
Hi,
I got the second code (using border option only after the image name).
I have couple of doubt on -splice. i tried giving
Code: Select all
convert image-0.jpg -background White -gravity east -splice 0+20x0+0 i__1.jpg;
convert image-0.jpg -background White -gravity west -splice 0+20x0+0 i__1.jpg;
Will add the white patch on middle of the image. But i wanted white patch on the left and right side of the image. By the way what does
mean? i tried changing it to
Code: Select all
0+0x20+0+0 OR 0+0x20+0 OR 0+0+0x20
and all the time i get the error
Code: Select all
convert: invalid argument for option `0+20x0+0': -splice.
and so on.
I need some option for adding white patch to the right or left side of the image, (Since -border adds to both the sides, its not useful in this case).
Pls assist.
Thanks,
ShekarKCB
Re: Overlaying a picture on a collage/montage (with mogrify)
Posted: 2010-02-23T22:47:29-07:00
by fmw42
see examples of splice with gravity east or west at
http://www.imagemagick.org/Usage/crop/#splice
-gravity east -splice 20x0
puts 20 pixels only on the east (right) side of the image.
Re: Overlaying a picture on a collage/montage (with mogrify)
Posted: 2010-02-23T23:12:43-07:00
by Chandrashekar Bhat
Thanks for the examples. But can anybody tell me what actually 20x0+0+0 or 0x20+0+ mean ? is it X , Y coordinates of the image or rows , columns ? what actually those 20, 0 ,0 mean and why + symbol comes there?
Thanks,
ShekarKCB
Re: Overlaying a picture on a collage/montage (with mogrify)
Posted: 2010-02-24T05:07:38-07:00
by snibgo
See
http://www.imagemagick.org/script/comma ... p#geometry
The format is one of:
axb+c+d
axb+c-d
axb-c+d
axb-c-d
Where a,b,c,d are integers. Generally:
a is width
b is height
c is x-offset, so it may be negative
d is y-offset, so it may be negative
I don't suppose c and d would make any difference here. But I could be wrong; try it and see.
Re: Overlaying a picture on a collage/montage (with mogrify)
Posted: 2010-03-09T02:51:56-07:00
by ShekarKCB
Hi All,
thanks for the reply. I was trying couple of options to get this image,
Check the below image
Basically this image will come on a black background. If you see the third row , one black patch is inserted. How to get off with that?
Below is the code i used.
Code: Select all
echo -e "Entering Ist Image..\n"
convert image-0.jpg -resize 105x107 -quality 100 i0.jpg;
convert -border 14x14 -bordercolor white -quality 100 i0.jpg i_0.jpg;
echo -e "Entering II Image..\n"
convert image-1.jpg -resize 105x107 -quality 100 i1.jpg;
convert -border 14x14 -bordercolor white -quality 100 i1.jpg i_1.jpg;
echo -e "Entering III Image..\n"
convert image-2.jpg -resize 105x107 -quality 100 i2.jpg;
convert -border 14x14 -bordercolor white -quality 100 i2.jpg i_2.jpg;
echo -e "Entering IV Image..\n"
convert image-3.jpg -resize 105x107 -quality 100 i3.jpg;
convert i3.jpg -gravity east -splice 14x0 -gravity south -splice 0x14 -gravity west -splice 14x0 i_3.jpg
echo -e "Entering V Image..\n"
convert image-4.jpg -resize 105x107 -quality 100 i4.jpg;
convert i4.jpg -gravity east -splice 14x0 -gravity south -splice 0x14 -gravity west -splice 14x0 i_4.jpg
echo -e "Entering VI Image..\n"
convert image-5.jpg -resize 105x107 -quality 100 i5.jpg;
convert i5.jpg -gravity east -splice 14x0 -gravity south -splice 0x14 -gravity west -splice 14x0 i_5.jpg
echo -e "Entering VII Image..\n"
convert image-6.jpg -resize 105x107 -quality 100 i6.jpg;
convert i6.jpg -gravity east -splice 14x0 -gravity south -splice 0x14 -gravity west -splice 14x0 i_6.jpg
echo -e "Entering VIII Image..\n"
convert image-7.jpg -resize 105x107 -quality 100 i7.jpg;
convert i7.jpg -gravity east -splice 14x0 -gravity south -splice 0x14 -gravity west -splice 14x0 i_7.jpg
echo -e "Entering IX Image..\n"
convert image-8.jpg -resize 105x107 -quality 100 i8.jpg;
convert i8.jpg -gravity east -splice 14x0 -gravity south -splice 0x14 -gravity west -splice 14x0 i_8.jpg
echo -e "Adding composite..\n"
convert -size 400x400 xc:none i_0.jpg -geometry +0+0 -composite i_1.jpg -geometry +105+0 -composite i_2.jpg -geometry +210+0 -composite i_3.jpg -geometry +0+107 -composite i_4.jpg -geometry +105+107 -composite i_5.jpg -geometry +210+107 -composite i_6.jpg -geometry +0+214 -composite i_7.jpg -geometry +105+214 -composite i_8.jpg -geometry +210+214 -composite -trim combined.jpg;
Please assist me ...
Thanks
Re: Overlaying a picture on a collage/montage (with mogrify)
Posted: 2010-03-09T10:17:10-07:00
by fmw42
Why not use montage? It is a lot simpler.
Try
montage zelda3b.jpg zelda3b.jpg zelda3b.jpg \
zelda3b.jpg zelda3b.jpg zelda3b.jpg \
zelda3b.jpg zelda3b.jpg zelda3b.jpg \
-tile 3x3 -geometry +7+7 miff:- | \
convert - -bordercolor white -border 7 zelda_montage.jpg

Re: Overlaying a picture on a collage/montage (with mogrify)
Posted: 2010-03-10T02:07:47-07:00
by ShekarKCB
Seems 'montage' solves my problem. But is there any way i can play around border color of montage?
i tried this,
Code: Select all
montage -bordercolor black image-0.jpg image-1.jpg i.jpg
Gave me image of 'white' border rather than 'black', where i am wrong? Does the '-miff:-' option says about image compression level ?
Basically i need to play around border colors and see which looks great. (White or black..etc).
Thanks
Shekarkcb