Page 1 of 1

Copy-opacity to cut out transparent mask -composite problems

Posted: 2010-04-27T06:22:24-07:00
by weatherbadger
Hi

I'm trying to cut out a transparent mask-hole in my wave charts so an underlying land-map will show through in a web-browser.

I'm starting with http://www.weatherbadger.com/Charts/test/wave2.png

and have a landmask http://www.weatherbadger.com/Charts/tes ... transp.png - if you open this with GIMP you can see the land is transparent.

These two images are the same height but the wave2.png is slightly wider - with a colorbar on the right hand side.

I've got as far as:

Code: Select all

convert wave2.png wave_transp.png -compose copy-opacity -composite wave-no_cbar.png
which works BUT it is making the right hand side of the wave2.png transparent which cuts off the color-bar: http://www.weatherbadger.com/Charts/tes ... o_cbar.png
It would appear that my -composite is making everything outside the mask image tranparent also.

I've tried -gravity west but think I'm probably not using -composite right. I can change the landmask to a black rather than transparent image if that helps

Thanks for any suggestions.

WB

Re: Copy-opacity to cut out transparent mask -composite prob

Posted: 2010-04-27T08:09:48-07:00
by snibgo
You can give a third image that will limit the dimensions of the composite. As you want this limit to be the source image you can simply clone it:

convert wave2.png wave_transp.png +clone -compose copy-opacity -composite wave-with_cbar.png

Re: Copy-opacity to cut out transparent mask -composite prob

Posted: 2010-04-27T10:27:07-07:00
by weatherbadger
+Clone - I've never have come up with that.

Just tried it and it works. Brilliant.

Many thanks
WB

Re: Copy-opacity to cut out transparent mask -composite prob

Posted: 2010-04-27T10:38:10-07:00
by snibgo
Good stuff. Send a bit of sunshine over towards Cambridge, would you?

"-gravity West" shouldn't make any difference. The default is NorthWest, but your source and destination images are the same height so NorthWest, West and SouthWest should give the same result.

Re: Copy-opacity to cut out transparent mask -composite prob

Posted: 2010-04-27T20:34:39-07:00
by anthony
weatherbadger wrote:Hi

I'm trying to cut out a transparent mask-hole in my wave charts so an underlying land-map will show through in a web-browser.

I'm starting with http://www.weatherbadger.com/Charts/test/wave2.png

and have a landmask http://www.weatherbadger.com/Charts/tes ... transp.png - if you open this with GIMP you can see the land is transparent.
As the images already has transparency, then you want to use a duff-porter composition.
http://www.imagemagick.org/Usage/compose/#duff-porter

The composition names make it very obvious as to pick what compose method you want to use.