Page 1 of 1
Help me with composite and Inverse transparency
Posted: 2015-05-27T15:25:00-07:00
by kocoten1992
Hi,
I've searching and I found this
viewtopic.php?t=18842, but the image is gone, so please answer this again
Got 3 image below, layer1.png, layer2.png and result.png repsectively.
How could I produce the result (it is layer2 over layer1, but I got stuck at the end, when cutting the transparency).
Important note: the layer 1 could be white as well.
Many thanks
Re: Help me with composite and Inverse transparency
Posted: 2015-05-27T16:46:09-07:00
by fmw42
The image you uploaded or is being downloaded is in JPG format and has lost any transparency from the PNG original.
If you have the png original where the gray in layer 2 is transparent, then this is one way. There may be other more efficient methods.
Code: Select all
convert layer1.png \( layer2.png -alpha extract -negate \) -compose copy_opacity -composite layer3.png
The above is unix syntax. For windows do
Code: Select all
convert layer1.png ( layer2.png -alpha extract -negate ) -compose copy_opacity -composite layer3.png
Re: Help me with composite and Inverse transparency
Posted: 2015-05-27T16:52:09-07:00
by kocoten1992
fmw42 wrote:The image you uploaded or is being downloaded is in JPG format and has lost any transparency from the PNG original.
If you have the png original where the gray in layer 2 is transparent, then this is one way. There may be other more efficient methods.
...
Thanks you very much
, one more question, how this can be achive in php ?
Re: Help me with composite and Inverse transparency
Posted: 2015-05-27T18:28:52-07:00
by fmw42
one more question, how this can be achive in php ?
Just use the exec() function to enclose the same command.
Code: Select all
<?php
exec("convert layer1.png \( layer2.png -alpha extract -negate \) -compose copy_opacity -composite layer3.png 2>&1",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>
If you mean PHP Imagick, then you need to ask that on the Imagick forum below. I am not an Imagick user. Note that Imagick is not being kept current with Imagemagick and is not as full functioned. So PHP exec() is going to do the job all the time easily for a single IM command line.