3

I am using this code to resize images. The resize works just fine, except the image background changes from transparent to black. I would like to maintain the transparent background but haven't found a resource explaining how to do it.

https://jsfiddle.net/skwny/gh7c2mpa/

see fiddle

skwny
  • 2,930
  • 4
  • 25
  • 45

1 Answers1

4

For image transparency, you need a proper image format change image/jpeg to image/png

var dataUrl = canvas.toDataURL('image/png');
joyBlanks
  • 6,419
  • 1
  • 22
  • 47
  • 1
    A little more detail, any extension can be used as long as it's the same as the original file. – skwny Sep 08 '19 at 19:13