Page 1 of 1

Resize an overlay

Posted: 2010-10-29T07:18:44-07:00
by ProfessorJerk
I've been reading through docs and forum posts for a while now with no luck. I'm wondering if someone can suggest a solution. I would like to overlay one image onto another, while defining the size of the overlay.

Something like this:

Code: Select all

convert  C:/overlay.tif -geometry 960x540 C:\input.tif -compose multiply -gravity center -composite C:\output.tif
The problem I'm trying to over come is the input.tif is also resized. I'd like to be able to define the size of the overlay, and leave the original image alone.

Is that possible somehow?

Re: Resize an overlay

Posted: 2010-10-29T07:24:26-07:00
by Bonzo
Try using parentheses; this may not work but will give you the idea:

Code: Select all

convert  ( C:/overlay.tif -geometry 960x540 ) C:\input.tif -compose multiply -gravity center -composite C:\output.tif

Re: Resize an overlay

Posted: 2010-10-29T07:33:30-07:00
by ProfessorJerk
Excellent thanks.

Re: Resize an overlay

Posted: 2010-10-31T17:15:59-07:00
by anthony
Your terminalogy is wrong...

In your example; input.tif is the overlay or 'source' image, and overlay.tif is the background or 'destination' image.

Also I recommend NOT using -geometry for resizing images. As Bonzo said, use parenthesis, but replace -geometry with -resize.

The only thing you should use -geometry for in "convert" is for positioning of the 'overlay/source' image on top of the 'background/destination' image. It just makes things a lot clearer.

See IM Examples, Geometry (as resize)
http://www.imagemagick.org/Usage/resize/#geometry
and Geometry (as composition placement)
http://www.imagemagick.org/Usage/compose/#geometry

And finally examples on 'layering images' (compose, draw, flatten, etc...
http://www.imagemagick.org/Usage/layers/#convert

Re: Resize an overlay

Posted: 2010-10-31T17:25:57-07:00
by anthony
Taking another look...
ProfessorJerk wrote:

Code: Select all

convert  C:/overlay.tif -geometry 960x540 C:\input.tif -compose multiply -gravity center -composite C:\output.tif
The problem I'm trying to over come is the input.tif is also resized.
Both images should not be resized. The definition for -geometry in "convert" is that it should just resize the last image!
Hmmm quick test...

Code: Select all

convert granite: -geometry 50% rose:  +append  show:
That shows that only the first image "granite" was resized.
Replacing +append with -composite does nto change that result!

I see no bug! and I can't see input.tif becoming resized.
Unless you have a VERY old buggy version of Image Magick!!!!

Re: Resize an overlay

Posted: 2010-11-01T11:59:33-07:00
by ProfessorJerk
I'm not sure what your syntax represents. if granite: is a tag where do you load the image?

I'm using a custom build of imageMagick 6.6.3-2 2010-07-27. And although the parenthesis do fix the issue on Windows, it seems they won't parse on linux. So I'm actually back where I started.

Re: Resize an overlay

Posted: 2010-11-01T12:14:00-07:00
by Bonzo
On Linux you need to escape the parentases :?

So ( ) becomes \( \)

rose: and granite: are inbuilt images in IM and can be used by everyone who has IM installed to make sure everybody is using the same image.

In your case try:

Code: Select all

convert C:\input.tif C:/overlay.tif  -geometry 50% -gravity center -composite C:\output.tif

Re: Resize an overlay

Posted: 2010-11-01T18:59:22-07:00
by anthony
ProfessorJerk wrote:I'm not sure what your syntax represents. if granite: is a tag where do you load the image?
granite: rose: logo: are built in images. that is they come from data internal to the core library.
The pattern:{name} are the other built in images though these are designed to produce tiling patterns.

See image file format. built-ins
http://www.imagemagick.org/script/forma ... tin-images

Using built-ins as an image source means that a command will work for everyone, making it good for testing purposes.