Combine overlap of two images

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?".
Locked
TSchein
Posts: 2
Joined: 2019-07-15T19:28:46-07:00
Authentication code: 1152

Combine overlap of two images

Post by TSchein »

I'm trying to figure out how to combine two images, such that one of the images only appears where there is non-transparency in the other image. OK, that wasn't very clear. I'll explain with pictures. Consider these two images. In the second image, the gray area represents transparency.

Image Image

I want to combine them so that the circle is filled with content from the first image. So the result should look like this:

Image

Is there a way to do that?

246246
Posts: 200
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

Re: Combine overlap of two images

Post by 246246 »

If the gray area is your 2nd image is transparent,

Code: Select all

magick 1st.png 2nd.png -compose copy_opacity -composite result.png
will do the job.

TSchein
Posts: 2
Joined: 2019-07-15T19:28:46-07:00
Authentication code: 1152

Re: Combine overlap of two images

Post by TSchein »

That's it! Thanks!

Locked