Skip to content

EdgeIt

基于Canvas的智能图片描边处理库,自动提取透明图片的图像轮廓,并进行描边 | 在线演示

🚀 核心特性

  • 智能边缘检测算法
  • 抗锯齿描边渲染
  • 零依赖,纯原生实现

📦 安装方式

bash
npm install edgeit.js

🛠 基础用法

javascript
const processor = new EdgeIt({
    strokeColor: '#ff3b30', // 描边颜色
    strokeWidth: 4          // 描边宽度(像素)
});

// 处理网络图片
processor.process('https://example.com/image.jpg')
    .then(result => document.body.appendChild(result));

⚙️ 配置选项

参数类型默认值说明
strokeColorString#000000描边颜色(支持 CSS 颜色格式)
strokeWidthNumber2描边宽度(像素)
cacheBooleantrue缓存图片对象,下次不用重新加载
willReadFrequentlyBooleantrue启用抗锯齿
imageSmoothingBooleantrue启用imageSmoothing
widthNumbernull指定输出图像的宽度 (可选)
heightNumbernull指定输出图像的高度(可选)