I’m trying to apply a mask as it works in Photoshop. Black is transparent, white is visible. However, the composite modes don’t allow for this, I think.
I can only find modes where it uses the alpha channel, but I’d like to use a jpg for smaller filesize…
2
Answers
Use getImageData and putImageData to access raw pixel data
You need to manually move the pixels.
To do this load the image, put it onto a canvas, get the canvas pixels. Convert to greyscale and move to alpha. THen put the pixels back onto the canvas.
Once loaded mask is a copy of the image with the alpha channel contains the mean of the RGB channels.
To use it
I tried to run your code, but unfortunately it didn’t work as expected.
I would also like this solution. Could anyone fix it?