javascript - How do I merge two transparent png files in Cordova -
i have 2 transparent png files identical width , height in cordova/ionic app. wish combine 2 png files new png file of same width , height 1 file overlayed on top of other file. i.e., 1 image layer on top of image. result must transparent png. how can in javascript cordova app? you adding both images canvas create on fly, or have in dom not displayed, read canvas using canvas' todataurl("image/png"). use 2d context on canvas load images in. something like: var canvas = document.getelementbyid('mycanvas'); // or create 1 don't display var ctx = canvas.getcontext('2d'); var image1 = '<image url>'; var image2 = '<image url>'; var image = new image(); var compositeimage; image.src = image1; ctx.drawimage(image, 0, 0); image = new image(); image.src = image2; ctx.drawimage(image, 0, 0); compositeimage = canvas.todataurl("image/png"); compositeimage has data url of composite image can use whatever ...