Blend images with gradient.

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
dognose
Posts: 265
Joined: 2005-03-08T22:16:37-07:00

Blend images with gradient.

Post by dognose »

Hi,

I'm trying to blend images together sorta like this:

Image

I tried the examples, and one looked really promising, but didn't work:

convert tile_aqua.jpg tile_water.jpg -size 94x94 gradient: +matte -composite water_shallows.jpg

Maybe it doesn't work on my version 6.2.8 (I've had problems getting an upgrade) Any tips on getting
this working?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Blend images with gradient.

Post by anthony »

There was a version where that scheme failed, you seemed to have found it!

In short the use of a masked composition is not finalized, as it only works with images that have no alpha channel to start with, and only the default 'over' composition is used. though that appears to be what you want.

Upgrade, to fix.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
dognose
Posts: 265
Joined: 2005-03-08T22:16:37-07:00

Re: Blend images with gradient.

Post by dognose »

Boy, I wish I could upgrade to the latest version.. however, it won't even install on the latest RH release.

6.2.9 was the version I was testing it on. I can't update the server version, and the anything newer from IM won't install.

Was there a work around for the version that didn't work?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Blend images with gradient.

Post by anthony »

Even if you do, I don't recomend using the 3 image composite to merge two images into each other.

Better to add transparnecy to edge of one image, then overlay that image with the appropriate offsets over the enlarged area of the other image.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
dognose
Posts: 265
Joined: 2005-03-08T22:16:37-07:00

Re: Blend images with gradient.

Post by dognose »

Well, that sounds like exactly what I'd want to do.

How would I "add transparency to edge of one image" ?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Blend images with gradient.

Post by Bonzo »

There is an example near the bottom of this page:
http://www.imagemagick.org/Usage/compose/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Blend images with gradient.

Post by anthony »

dognose wrote:How would I "add transparency to edge of one image" ?
You create a gradient image, and set that as the overlay images alpha channel.
That is actually what the 3 image blend is currently doing, though that is not what it should be doing (for overlay the current method works well, just not for other composition methods) Of course your IM is not doing either, so you need to DIY it.

Code: Select all

  compose   overlay_image.jpg mask_image.jpg \
          +matte -compose CopyOpacity -composite \
          \( background_image.jpg  ...add space for overlay image... \) \
          +swap -geometry +Xoffset+0  +compose -composite \
          save_image.jpg
You still need to create your mask, (which I think may be smaller than the image it is being added to, not sure) add space to the background image to fit the new one, if needed, and supply the Xoffset for the overlay. But that is basically it.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
dognose
Posts: 265
Joined: 2005-03-08T22:16:37-07:00

Re: Blend images with gradient.

Post by dognose »

Great! Thank you. I'm finally getting results.

I think the command you used there was "convert" and not "compose".
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Blend images with gradient.

Post by anthony »

Opps yes -- convert. A typo... I was thinking of compositing images!

"Bad spellers of the world, UNTIE!"
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply