idwall / idcrop

Polygonal image cropping plugin.
MIT License
18 stars 9 forks source link

IdCrop

code style: prettier

Image cropper utility that crops an image in any polygonal shape chosen and returns a base64 of the cropped area.

Demo: https://idwall.github.io/idcrop/

Usage

$ npm install idcrop
Javascript
const IdCrop = require("idcrop");

const idcrop = new IdCrop({
  displaySelector: "#display",
  toolbarSelector: "#toolbar",
  previewSelector: "#preview"
});

idcrop.init();
Configuration Object

The only required key in the configuration object is the CSS selector for the display area, but we have a bunch of configuration options that will be listed below.

Events

Some events are dispatched to the document in some key actions done to the cropper. These events are:

Getters

Right now we only have one getter method for the IdCrop which is:

HTML

You can create a container for display (cropping area), toolbar (for now, only filename) and preview (cropped area preview). Only the display area is required though.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>IdCrop</title>
    <link rel="stylesheet" type="text/css href="https://unpkg.com/idcrop@1.2.2/dist/css/main.min.css">
  </head>

  <body>
    <div id="display"></div>
    <div id="toolbar"></div>
    <div id="preview"></div>
  </body>
</html>

Development Environment Setup

$ npm install & npm start
Linting

We use a combination of eslint and prettier for the formatting and linting of our JS code.

$ npm run lint
$ npm run fix
Publishing

We have a small npm script that handles the bumping of the version and the publishing of the package for us.

$ npm --no-git-tag version <newversion>

License

Copyright © 2017, Idwall. Released under the MIT license.