Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cropperjs

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cropperjs

JavaScript image cropper.

  • 1.6.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
798K
decreased by-0.23%
Maintainers
1
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

FAQs

Package last updated on 21 Apr 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc