Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a image from PNG to JPEG using javascript?

Tags:

I am trying to get image from canvas. enter image description herePNG image is coming properly but the JPEG is producing a problem. I attached image here.First image is my canvas.Followed by PNG then JPEG.So i want my JPEG image with white background or i need a solution for PNG to JPEG conversion in JS

canvas =  $('.jSignature')[0];

            imgData = canvas.toDataURL();
            imgDatajpeg = canvas.toDataURL("image/jpeg");                   

            $(".sigCapHolder").append('<img src='+imgData+' /> ')
            $(".sigCapHolder").append('<img src='+imgDatajpeg+' /> ')