image-clip
v1.0.1
Published
A plugin for cropping images, using canvas to convert cropped images to base64.
Downloads
3
Readme
Image Clip
A plugin for cropping images, using canvas to convert cropped images to base64.
Usage
Install
npm i image-clip -S
Import into your project when the download is complete.
import ImageClip from 'image-clip';
Initialize
Create a instance of ImageClip plugin. Container is the parent node of ImageClip.
const imgClip = new ImageClip(container);
Set source and width
Image must be an instance of Image, width is the width of the ImageClip container.
imgClip.setSource(image, width);
Drag the bounds of image.
Save the modified picture.
Crop the picture to a specified size, and convert the result to base64.
const path = imgClip.save(width, height);
License
MIT