skwny
skwny

Reputation: 3140

How to resize image - and keep transparent background

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

Upvotes: 3

Views: 1769

Answers (1)

Joy Biswas
Joy Biswas

Reputation: 6527

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

var dataUrl = canvas.toDataURL('image/png');

Upvotes: 4

Related Questions