2ndGAB 2ndGAB - 1 year ago 59
HTML Question

Cannot correctly resize an image at less than 60%

I've implemented a background color modification based on this post

But I want to modify my image size and when I set it below 60%, the image is cropped instead of being resized.

I saw that the problem come from the function

but I cannot understand why.

Could you have look at his fiddle and change the width of
to 50% for example to see the problem?

Answer Source

You needed to pass the image width/height when using drawImage


var ctx = canvas.getContext("2d");