Hi forum,
I'm not sure if what I want can be accomplished with either ImageMagick's convert or montage. I've tried both and failed miserably. Most examples I found are too easy and don't do what I want. Here's the problem description:
I have n source Images. Let's say 3 sources, A.png B.png and C.png. I want to have a single destination image, X.png.
X.png shall have a fixed size, let's say 1000x1000 px. It shall have a white background and contain:
The region 10x13+15+17 of A.png at 400,410.
The region 20x23+25+27 of B.png at 300,310
The region 30x33+35+37 of C.png at 200,210
Is this possible with one single convert/montage command? If so, how?
Thanks,
Jeremy
Stiching images
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Stiching images
It would go something like this:
Adjust for your platform (Unix, Windows, whatever).
Code: Select all
convert
-size 1000x1000 xc:white
( A.png -crop 10x13+15+17 +repage ) -geometry 400,410 -composite
( B.png -crop 20x23+25+27 +repage ) -geometry 300,310 -composite
( C.png -crop 30x33+35+37 +repage ) -geometry 200,210 -composite
X.png
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Stiching images
It is best to always provide your IM version and platform. There are syntax differences between Linux/Mac OS vs Windows. To provide the exact command line syntax, we need to know your platform.
Re: Stiching images
Linux complains about the -geometry
I think they should be +X+Y instead of X,Y
Using this on Linux (Ubuntu 14.04 LTS) with IM-6.8.9-7, with the parentheses escaped,
works for me.
I think they should be +X+Y instead of X,Y
Using this on Linux (Ubuntu 14.04 LTS) with IM-6.8.9-7, with the parentheses escaped,
Code: Select all
convert \
-size 1000x1000 xc:white \
\( A.png -crop 10x13+15+17 +repage \) -geometry +400+410 -composite \
\( B.png -crop 20x23+25+27 +repage \) -geometry +300+310 -composite \
\( C.png -crop 30x33+35+37 +repage \) -geometry +200+210 -composite \
X.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Stiching images
For (unix) reference, see
http://www.imagemagick.org/Usage/layers/#convert
I believe the windows equivalent is
http://www.imagemagick.org/Usage/layers/#convert
I believe the windows equivalent is
Code: Select all
convert ^
-size 1000x1000 xc:white ^
( A.png -crop 10x13+15+17 +repage ) -geometry +400+410 -composite ^
( B.png -crop 20x23+25+27 +repage ) -geometry +300+310 -composite ^
( C.png -crop 30x33+35+37 +repage ) -geometry +200+210 -composite ^
X.png
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Stiching images
Yeah, sorry, "+400+410" etc not "400,410". Gosh, I'm getting stupid.
snibgo's IM pages: im.snibgo.com
Re: Stiching images
Aaaaaaaaaah thank you guys so much! The parentesis was what I was missing (becuase I played with those switches but they always applied to the wrong portion of the image). Thank you so so much! This is perfect! Woooo! 
I'm on Linux x86_64, but I'm not using a shell so I won't have to worry about escaping parenthesis (forking/execing directly). Didn't know however that ImageMagick behaved differently across platforms, so I'll keep that in mind for the future.
Thanks again.
Jeremy

I'm on Linux x86_64, but I'm not using a shell so I won't have to worry about escaping parenthesis (forking/execing directly). Didn't know however that ImageMagick behaved differently across platforms, so I'll keep that in mind for the future.
Thanks again.
Jeremy
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Stiching images
It doesn't. It is the platforms that are different.zahnrad wrote:Didn't know however that ImageMagick behaved differently across platforms, so I'll keep that in mind for the future.
snibgo's IM pages: im.snibgo.com