✂ Cropnow
Fast and simple image cropper utility with Zero dependencies.
Install
npm i cropnow --save
yarn add cropnow
Or include it via jsDelivr CDN (UMD):
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/cropnow/index.css" />
<script src="https://cdn.jsdelivr.net/npm/cropnow/index.js"></script>
Usage
import 'cropnow/index.css'
import Cropnow from 'cropnow'
Example
const container = document.getElementById('container')
const options = {
url: 'example.jpg',
preview?: document.getElementById('preview'),
onCropEnded?:({ canvas, data }) => {
console.log(canvas, data)
}
}
const cropper = new Cropnow(container, options)
Methods
download image as png.
download image as jpeg.
Get the original size of image and current position of crop box.
- getCanvas(): HTMLCanvasElement
Get a canvas element with cropped image drawn.
Reset crop box.
License
MIT