本文共 1123 字,大约阅读时间需要 3 分钟。
Html的Canvas主要通过js脚本做一些图形化操作。Canvas是一个矩形区域,您可以控制其每一像素。canvas 拥有多种绘制路径、矩形、圆形、字符以及添加图像的方法。
如果有个需求,我们只想要用户相册图片中某个区域的内容,其余区域设为透明?
// Resize from Canvas/Image to another Canvaspica.resize(from, to, { unsharpAmount: 80, unsharpRadius: 0.6, unsharpThreshold: 2}).then(result => console.log('resize done!'));
ctx.save();ctx.drawImage(mask_img, 0, 0);ctx.globalCompositeOperation = "source-in";ctx.drawImage(our_img, 0, 0);ctx.restore();
var gif = new GIF({ workers: 2, quality: 10, background: "#ffffff00", transparent:"ff0000" }); gif.addFrame(img1); gif.addFrame(img2); gif.on('finished', function(blob) { // window.open(URL.createObjectURL(blob)); var url = URL.createObjectURL(blob); document.getElementById("gif").setAttribute("src",url) }); gif.render();
这里主要介绍了一些前端对图片处理的操作。
转载地址:http://frwsl.baihongyu.com/