I am unable to figure out how to do this from the manual, maybe someone here can shed some light?
I want to multiply image A over image B. Image A is a different resolution from image B, so I want to resize A to match B and then multiply it over in a single line. Is this possible? Do I need to know the resolution of A before I write out the line? I was hoping there was a "fit" resize method. Thanks everyone!
Resizing overlay image at the same time as overlaying?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Resizing overlay image at the same time as overlaying?
Code: Select all
compose imageB.png \( imageA.png -resize WxH \) -composite result.png
Code: Select all
compose imageB.png imageA.png -geometry XwH -composite result.png
Code: Select all
composite imageA.png imageB.png -geometry XwH -composite result.png
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Resizing overlay image at the same time as overlaying?
Is there a way of doing this if you don't know the resolution of image A?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Resizing overlay image at the same time as overlaying?
In a script or two line command, you can extract the size in one command and use it in the second.
size=`convert imageB -format "%wx%h" info:`
convert imageB.png \( imageA.png -resize "$size" \) -compose multiply -composite result.png
This will compute the size of imageB, then resize imageA to the size of imageB, then multiply the two to composite them.
see string formats at http://www.imagemagick.org/script/escape.php
the above is for unix, for windows see http://www.imagemagick.org/Usage/windows/
size=`convert imageB -format "%wx%h" info:`
convert imageB.png \( imageA.png -resize "$size" \) -compose multiply -composite result.png
This will compute the size of imageB, then resize imageA to the size of imageB, then multiply the two to composite them.
see string formats at http://www.imagemagick.org/script/escape.php
the above is for unix, for windows see http://www.imagemagick.org/Usage/windows/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Resizing overlay image at the same time as overlaying?
If you know thw resolution you want you can do a -resample Which is really just a resize to a specific resolution. See IM Examples, Resample
http://www.imagemagick.org/Usage/resize/#resample
http://www.imagemagick.org/Usage/resize/#resample
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Resizing overlay image at the same time as overlaying?
Thanks everyone you guys rock! I appreciate the help very much.
Re: Resizing overlay image at the same time as overlaying?
For anyone else taking a look at this thread there is one thing I had to change in the command. -resize widthxheight\!
the \! made sure to ignore the orginal file's aspect ratio. This will ensure that A completely covers B. Otherwise it wont unless they are the same aspect ratio.
the \! made sure to ignore the orginal file's aspect ratio. This will ensure that A completely covers B. Otherwise it wont unless they are the same aspect ratio.
Re: Resizing overlay image at the same time as overlaying?
In order to have the entire image covered and keep the aspect ratio, couldn't the caret geometry argument be used instead? =)
-resize WxH^
If I haven't entirely misunderstood that will use the first minimum dimension (either width or height) that fits and lets the other dimension adapt, while maintaining the aspect ratio.
http://www.imagemagick.org/script/comma ... p#geometry
-resize WxH^
If I haven't entirely misunderstood that will use the first minimum dimension (either width or height) that fits and lets the other dimension adapt, while maintaining the aspect ratio.
http://www.imagemagick.org/script/comma ... p#geometry
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Resizing overlay image at the same time as overlaying?
The ^ will resize preserving aspect, but the smaller dimension of the image will be matched to the specified arguments and the larger dimension will be larger than specified according to the aspect. Thus you may want to crop your image, but that would then destroy the aspect ratio. There is no way to preserve aspect ratio if the specified arguments aspect ratio do match that of the image, unless you are willing to accept distorting in one dimension or the other. This option is the ! option.