So my client-side code recieves two PNG images. One of them is half-transparent. How can i overlay first image with the second one and convert it to third PNG file to use it later?
It like using them as layers to make 1 PNG image.
Is there any way to do it or any frameworks?
So my client-side code recieves two PNG images. One of them is half-transparent. How
Share
Its really easy to do. You just need to use
drawImageto draw the images onto the canvas in layers. As for saving, you usetoDataURLwhich will return a base64 url for the image, which you can then do whatever with, open in a new window etc. However the images must come from the domain the code is running on in order to get the data url, or a security exception will be thrown. The jsfiddle example throws the security exception because Im pulling images from two random websites just as an example.Live Demo