Blendmode "screen" on transparent canvas

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
higoka
Posts: 17
Joined: 2019-04-22T16:36:51-07:00
Authentication code: 1152

Blendmode "screen" on transparent canvas

Post by higoka »

I need to compose three images together.
The problem is image b_4_0.png is opaque and has transparency (semi-transparent). The black pixels should not be there.

Code: Select all

magick -size 300x300 canvas:transparent \
  img/a_4_0.png -geometry +114+55 -compose over -composite \
  img/b_4_0.png -geometry +109+75 -compose screen -composite \
  img/c_4_0.png -geometry +118+119 -compose over -composite \
  result.png
Result:
Image

What it should look like:
Image

Code: Select all

magick identify -format '%[opaque]' img/a_4_0.png # false
magick identify -format '%[opaque]' img/b_4_0.png # true
magick identify -format '%[opaque]' img/c_4_0.png # false
The image b_4_0.png is opaque, sure it has to do something with this or the min max mean values

Images: img.zip
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Blendmode "screen" on transparent canvas

Post by snibgo »

"screen" affect alpha in the same was as "over" affects alpha: where a source pixel is opaque, the result is opaque.

If you don't want this, your can extract the alpha to mpr, then "CopyOpacity" after the "screen".
snibgo's IM pages: im.snibgo.com
higoka
Posts: 17
Joined: 2019-04-22T16:36:51-07:00
Authentication code: 1152

Re: Blendmode "screen" on transparent canvas

Post by higoka »

can you give me an example
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Blendmode "screen" on transparent canvas

Post by snibgo »

Code: Select all

magick -size 300x300 canvas:transparent \
  a_4_0.png -geometry +114+55 -compose over -composite \
  \( +clone -alpha extract +write mpr:ALP +delete \) \
  b_4_0.png -geometry +109+75 -compose screen -composite \
  mpr:ALP -alpha off -geometry +0+0 -compose CopyOpacity -composite \
  c_4_0.png -geometry +118+119 -compose over -composite \
  result.png
snibgo's IM pages: im.snibgo.com
Post Reply