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

modal-cropper

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

modal-cropper

Promise-based, simplified, single-function library for very basic image crop operation on browser side and in modal.

  • 1.2.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

modal-cropper

Promise-based, simplified, single-function library for very basic image crop operation on browser side and in modal.

This library depends on Tingle and Cropper.js.

Actually all this library do is to wrap this two libraries into very simple function that just work for specific purpose.

Installation and Usage

  1. Install the package with your favorite package manager:
npm install --save modal-cropper
  1. Include css files of dependencies:
@import url('~tingle.js/dist/tingle.css');
@import url('~cropperjs/dist/cropper.css');
  1. Import and call the library:
var cropper = require('modal-cropper');

async function someFunction() {
  // assuming user choose an image from input
  // var file = file_input[0].files[0];
  // or you have a Blob object with 

  // and you want 1920x1080 JPG image from it
  try {
    var result = await cropper(file, 1920, 1080, 'jpg');
    if(result) {
      // call your favorite http client to upload the picture
    } else {
      // user cancelled the operation
    }
  } catch(e) {
    // some exception occur
  }
}

This library supports CommonJS and AMD specs, if you do not use a proper CommonJS or AMD loader, you need to include Tingle, Cropper.js and index.js and use window.modal_cropper in your code.

If you use ES5 syntax in your project, instead of using await, you can use .then to get the results from this library.

Contributing

Pull requests and issues are welcome!

License

© 2018 Burak Tamturk © 2018 Robin Parisi
© 2015 Chen Fengyuan

Released under the MIT LICENSE

FAQs

Package last updated on 12 Feb 2021

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