- Joined
- Feb 28, 2016
- Messages
- 7
- Reaction score
- 1
- First Language
- english
- Primarily Uses
Hi, hope that I can find some help here.
I trying to merge 2 .png into 1 and then save it. Basically it for my character face or so call ingame creator.
I try to use below script althou there no error, but it not working.
var c = document.createElement('canvas');
var ctx = c.getContext('2d');
var image1 = new Image();
var image2 = new Image();
image1.src = "1.png"
image1.onload = function() {
ctx.drawImage(image1, 0, 0, 142, 142);
image2.src = "2.png";
image2.onload = function() {
ctx.drawImage(image2, 0, 0, 142, 142);
var img = c.toDataURL("image/png");
document.write('<img src="' + img + '" width="142" height="142"/>');}};
Will be grateful if can get this working or that another way to merge n save png
Cheers
Mike
I trying to merge 2 .png into 1 and then save it. Basically it for my character face or so call ingame creator.
I try to use below script althou there no error, but it not working.
var c = document.createElement('canvas');
var ctx = c.getContext('2d');
var image1 = new Image();
var image2 = new Image();
image1.src = "1.png"
image1.onload = function() {
ctx.drawImage(image1, 0, 0, 142, 142);
image2.src = "2.png";
image2.onload = function() {
ctx.drawImage(image2, 0, 0, 142, 142);
var img = c.toDataURL("image/png");
document.write('<img src="' + img + '" width="142" height="142"/>');}};
Will be grateful if can get this working or that another way to merge n save png
Cheers
Mike

