npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

idcrop

v2.1.3

Published

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

Downloads

131

Readme

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.

  • displaySelector CSS selector for the containerof the display area (required, type CSS Selector)
  • toolbarSelector CSS selector for the container of the toolbar (default "" type CSS Selector)
  • previewSelector CSS selector for the container of the preview area (default "" type CSS Selector)
  • closeButtonSelector CSS selector for the close button when Inifity is the number of points (default "" type CSS Selector)
  • allowUpload Wether or not to allow image upload (default true type boolean)
  • numPoints Number of points (default 4 type integer)
  • croppingArea
    • overlayColor The color of the overlay around the cropping area (default "rgba(0, 0, 0, 0.7)" type CSS colors)
    • stroke Wether or not to add a stroke around the cropping area (default true type boolean)
    • strokeColor The color of the stroke around the cropping area (default "white" type CSS colors)
    • strokeDashed Wether or not the stroke is dashed (default true type boolean)
    • strokeWeight The weight of the stroke around the cropping area (default 2 type integer)
  • crop
    • overlayColor The color of the overlay around the crop (default "rgba(0, 0, 0, 0)" type CSS colors)
    • fillColor The color of the fill inside the crop (default false type boolean)
    • showImage Wether or not to show the image inside the crop polygon. (default true type boolean)
    • stroke Wether or not to add a stroke around the crop (default false type boolean)
    • strokeColor The color of the stroke around the crop (default false type boolean)
    • strokeDashed Wether or not the stroke is dashed (default false type boolean)
    • strokeWeight The weight of the stroke around the cropping area (default 0 type integer)
  • handles
    • class Any aditional classes to be added to the handles (default "" type string)
    • defaultStyles Wether or not to add the default styles to the handles. (default false type boolean)
Events

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

  • created Dispatched when the IdCrop is loaded or reset. detail The IdCrop configuration object.
  • handleCreated Dispatched when a new handle is created. detail The x and y position of the created handle.
  • resized Dispatched when a handle is moved. detail The new x and y position of the moved handle.
  • crop Dispatched when a crop action happens. detail The dataURI for the image created.
Getters

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

  • idcrop.getPoints This method returns a list with all the points added to the image relative to the real image size.
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/[email protected]/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.