
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
CropperJS is a JavaScript library that provides a simple and easy-to-use interface for cropping images. It offers a variety of features such as zooming, rotating, and scaling images, making it a versatile tool for image manipulation in web applications.
Basic Image Cropping
This feature allows you to crop an image with a specified aspect ratio. The `crop` event provides details about the cropping area, such as its position and dimensions.
const image = document.getElementById('image');
const cropper = new Cropper(image, {
aspectRatio: 16 / 9,
crop(event) {
console.log(event.detail.x);
console.log(event.detail.y);
console.log(event.detail.width);
console.log(event.detail.height);
console.log(event.detail.rotate);
console.log(event.detail.scaleX);
console.log(event.detail.scaleY);
},
});
Zooming
This feature allows you to zoom in and out of the image. The `zoom` event provides the current zoom ratio.
const cropper = new Cropper(image, {
zoom(event) {
console.log(event.detail.ratio);
},
});
Rotating
This feature allows you to rotate the image by a specified degree. In this example, the image is rotated by 45 degrees.
cropper.rotate(45);
Scaling
This feature allows you to scale the image horizontally or vertically. In this example, the image is flipped horizontally.
cropper.scaleX(-1);
React Image Crop is a library specifically designed for React applications. It provides similar functionalities to CropperJS, such as image cropping and aspect ratio control. However, it is more tailored for use with React components, making it a better choice for React developers.
Ngx Image Cropper is an Angular library for cropping images. It offers similar features to CropperJS, including aspect ratio control and image manipulation. This package is more suitable for Angular applications, providing a seamless integration with Angular components.
Vue Cropper is a Vue.js component for image cropping. It provides functionalities similar to CropperJS, such as zooming, rotating, and scaling images. This package is designed to work well within Vue.js applications, offering a more native experience for Vue developers.
JavaScript image cropper.
dist/
āāā cropper.js (UMD, bundled)
āāā cropper.min.js (UMD, bundled, compressed)
āāā cropper.raw.js (UMD, unbundled, default)
āāā cropper.esm.js (ECMAScript Module, bundled)
āāā cropper.esm.min.js (ECMAScript Module, bundled, compressed)
āāā cropper.esm.raw.js (ECMAScript Module, unbundled)
āāā cropper.d.ts (TypeScript Declaration File)
npm install cropperjs
import Cropper from 'cropperjs';
const image = new Image();
image.src = '/path/to/image.jpg';
const cropper = new Cropper(image);
Maintained under the Semantic Versioning guidelines.
2.0.0 (2025-03-01)
"scale"
option for the event.detail.action
of actionstart/move/ (c778cb6)FAQs
JavaScript image cropper.
The npm package cropperjs receives a total of 965,563 weekly downloads. As such, cropperjs popularity was classified as popular.
We found that cropperjs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Ā It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.