šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
DemoInstallSign in
Socket

cropperjs

Package Overview
Dependencies
Maintainers
0
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cropperjs

JavaScript image cropper.

2.0.0
latest
Source
npm
Version published
Weekly downloads
964K
11.17%
Maintainers
0
Weekly downloads
Ā 
Created

What is cropperjs?

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.

What are cropperjs's main functionalities?

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);

Other packages similar to cropperjs

Keywords

image

FAQs

Package last updated on 01 Mar 2025

Did you know?

Socket

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.

Install

Related posts