Image Editor


Keywords
image, react, image-editor, typescript, component
License
MIT
Install
npm install image-editor-little@0.1.5

Documentation

image-editor

Build Status npm npm bundle size NPM

这是一个React截图工具的组件, 基本功能和微信截图相似, 因为使用了React Hooks, 所以对React的版本有一定要求,支持的功能:

  1. 截取图片,下载处理好的图片
  2. 矩形和圆形标注功能
  3. 手写功能
  4. 马赛克功能
  5. 撤销操作

后续看情况拓展功能和优化

install

yarn add image-editor-little

or

npm install -S image-editor-little

example

import ImageEditor from 'image-editor-little';

<ImageEditor
  width={500}
  height={500}
  src="https://miro.medium.com/max/3200/1*hLM2qGfy0VOTiyuyE3pOBA.png"
/>

online

image-editor-little-demo

网页截图

给网页添加截图功能, 目前不会加这个功能, 不想依赖 html2canvas

image-editor-little-demo

api

参数 说明 类型 默认值 是否必填
src 图片的 src string -
width 宽度 number -
height 高度 number -
className 自定义类名 string -
imageType 下载图片格式类型 string png
locSize 放大镜大小(x 10) number 10
holdSize 图片加载时, 占位 svg 宽高 object { w: '100vw', h: '100vh' }
onClose 点击 X 触发 (close: () => void) => void -
onDownload 点击下载触发 (close: () => void) => void -
onConfirm 点击确认触发 (url?: string, close?: () => void) => void -