Resizing an image in an HTML5 canvas

后端 未结 18 3013
半阙折子戏
半阙折子戏 2020-11-22 03:37

I\'m trying to create a thumbnail image on the client side using javascript and a canvas element, but when I shrink the image down, it looks terrible. It looks as if it was

18条回答
  •  一整个雨季
    2020-11-22 03:47

    Looking for another great simple solution?

    var img=document.createElement('img');
    img.src=canvas.toDataURL();
    $(img).css("background", backgroundColor);
    $(img).width(settings.width);
    $(img).height(settings.height);
    

    This solution will use the resize algorith of browser! :)

提交回复
热议问题