August 8, 2022

(base64) Pure JavaScript Image Cropping Functionality To Your Web | js-cropper

js-cropper is a quick and easy way to add image cropping functionality to your web application without dependencies.

image cropper js, cropper js download, cropper js example code, cropper js set width height, javascript crop image before upload


  • Promise API
  • Supports Touch Events
  • Multiple callbacks
  • No dependencies (pure JavaScript code)
  • Excellent Browser support
  • Based on canvas technology
  • Available Zooming (Setting/Resetting/UI input)
  • Exports cropped image in Base64
  • Gets position/zoom in JSON data
  • Sets position/zoom from JSON data
  • Dynamically changing dimensions of cropping area via available public methods
  • Loads image by URL
  • and many others…

How to make use of it:

1. Install js-cropper.js library.

# Yarn
$ yarn add js-cropper
$ npm install js-cropper --save

2. Import js-cropper.js and js-cropper.css into the project.

// ES 6
import Cropper from 'js-cropper';
// CommonJS:
const Cropper = require('js-cropper');

3. Create a container element for the cropping area.

<div id="crop"></div>

4. Configure the image trimmer with the default settings.

const cropper = new Cropper();

5. Upload the photo you want to crop.

cropper.loadImage("/path/to/image.jpg").then(function (crop) {"Image is ready to crop.");

6. Export the cropped image in Base64.


7. Default options and callback functions.

const cropper = new Cropper({
      width: 560,
      height: 340,
      onInit: function (crop) {},
      onChange: function(crop) {}

8. More API methods.

const cropper = new Cropper({
      // options here
// Changes Image Crop width.
// Changes Image Crop height.
// Sets zoom level. 
// Gets data in JSON
// Sets data from JSON
// Reset

touch-enabled image cropper, js-cropper Plugin/Github

See Demo And Download

Official Website(denis-kalinichenko): Click Here

This superior jQuery/javascript plugin is developed by denis-kalinichenko. For extra advanced usage, please go to the official website.


You may also like...

Leave a Reply

Your email address will not be published.