(recommended)
Run npm install js-cropper --save
var Cropper = require("js-cropper");
import Cropper from "js-cropper";
<div id="crop"></div>
<link rel="stylesheet" href="../js-cropper/dist/Cropper.css">
Finally, we need to initialize Cropper in JavaScript code.
const cropper = new Cropper();
cropper.render("#crop");
cropper.loadImage("/path/to/image.jpg").then(function (crop) {
console.info("Image is ready to crop.");
});
Go to API Documentation to learn more about all Cropper API and how to control it.