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

react-easy-crop

Package Overview
Dependencies
Maintainers
1
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-easy-crop

A React component to crop images/videos with easy interactions

  • 5.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
387K
increased by5.17%
Maintainers
1
Weekly downloads
 
Created

What is react-easy-crop?

react-easy-crop is a React component to crop images and videos. It provides a simple and customizable interface for cropping media, making it easy to integrate into your React applications.

What are react-easy-crop's main functionalities?

Basic Image Cropping

This feature allows you to crop an image with adjustable crop and zoom settings. The aspect ratio can also be set to maintain a specific ratio during cropping.

import React, { useState } from 'react';
import Cropper from 'react-easy-crop';

const ImageCropper = () => {
  const [crop, setCrop] = useState({ x: 0, y: 0 });
  const [zoom, setZoom] = useState(1);

  return (
    <div>
      <Cropper
        image="/path/to/image.jpg"
        crop={crop}
        zoom={zoom}
        aspect={4 / 3}
        onCropChange={setCrop}
        onZoomChange={setZoom}
      />
    </div>
  );
};

export default ImageCropper;

Video Cropping

This feature allows you to crop a video with adjustable crop and zoom settings. The aspect ratio can also be set to maintain a specific ratio during cropping.

import React, { useState } from 'react';
import Cropper from 'react-easy-crop';

const VideoCropper = () => {
  const [crop, setCrop] = useState({ x: 0, y: 0 });
  const [zoom, setZoom] = useState(1);

  return (
    <div>
      <Cropper
        video="/path/to/video.mp4"
        crop={crop}
        zoom={zoom}
        aspect={16 / 9}
        onCropChange={setCrop}
        onZoomChange={setZoom}
      />
    </div>
  );
};

export default VideoCropper;

Customizable Cropping Area

This feature allows you to get the cropped area details after cropping is complete. You can use this information to further process the cropped image or video.

import React, { useState } from 'react';
import Cropper from 'react-easy-crop';

const CustomCropper = () => {
  const [crop, setCrop] = useState({ x: 0, y: 0 });
  const [zoom, setZoom] = useState(1);
  const [croppedArea, setCroppedArea] = useState(null);

  const onCropComplete = (croppedArea, croppedAreaPixels) => {
    setCroppedArea(croppedAreaPixels);
  };

  return (
    <div>
      <Cropper
        image="/path/to/image.jpg"
        crop={crop}
        zoom={zoom}
        aspect={4 / 3}
        onCropChange={setCrop}
        onZoomChange={setZoom}
        onCropComplete={onCropComplete}
      />
      {croppedArea && (
        <div>
          <p>Cropped Area: {JSON.stringify(croppedArea)}</p>
        </div>
      )}
    </div>
  );
};

export default CustomCropper;

Other packages similar to react-easy-crop

Keywords

FAQs

Package last updated on 28 Nov 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