Resize an overlay

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
ProfessorJerk

Resize an overlay

Post 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?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Resize an overlay

Post 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
ProfessorJerk

Re: Resize an overlay

Post by ProfessorJerk »

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

Re: Resize an overlay

Post 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
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: Resize an overlay

Post 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!!!!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
ProfessorJerk

Re: Resize an overlay

Post 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.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Resize an overlay

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Resize an overlay

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply