I need to apply certain filters to the images (photos) as if it was in instagram or in a photoshop alike app. Filters come with different settings such as sepia, hue, gradients and compose modes. Where I get a problem is a multiply type of composition.
My filter is a half-transparent gradient such as this one (square):
![Image](https://fs2.fex.net/show/848171092496/1215419938/c14ad291/Overlay.png?1600w,0)
Taking this example image (also square and same size):
![Image](https://fs2.fex.net/show/848171092496/1215419875/134a2218/Image.png?1600w,0)
Applying this command
Code: Select all
magick convert Image.png Overlay.png -compose Multiply -composite Result1.png
![Image](https://fs2.fex.net/show/848171092496/1215419978/769af37f/Result1.png?1600w,0)
Of course, this is not what I am looking for so the solution is to specify the -channel parameter allowing to 'skip' the alpha
Code: Select all
magick convert Image.png Overlay.png -channel rgb -compose Multiply -composite Result2.png
![Image](https://fs2.fex.net/show/848171092496/1215420025/cb9df8b7/Result2.png?1600w,0)
But the MagickImage class in .NET does not have a Composite method overload that accepts Channels enum as a parameter.
So this line
Code: Select all
magickImage.Composite(overlay, CompositeOperator.Multiply);
So I would really appreciate if you could help me with this one.
P. S.
Multiplying as is and then removing transparency may look like a decent workaround at first, but there is a catch.
If an original image has its own transparency (even a small part of it does) like this
![Image](https://fs2.fex.net/show/848171092496/1215422978/c6c7c8e3/Image.png?1600w,0)
Then after composition you can't tell what part was transparent in the beginning and what got its alpha by multiplying a filter.
So if removed transparency at that point it will also lose the one it was supposed to have:
![Image](https://fs2.fex.net/show/848171092496/1215422992/03b5a5c7/Result.png?1600w,0)