Socket
Socket
Sign inDemoInstall

cropnow

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cropnow

Image cropper utility


Version published
Weekly downloads
4
increased by33.33%
Maintainers
1
Install size
58.4 kB
Created
Weekly downloads
 

Readme

Source

✂ Cropnow

Fast and simple image cropper utility with Zero dependencies.

Image cropper

Demo

Install

npm i cropnow --save
// or
yarn add cropnow

Or include it via jsDelivr CDN (UMD):

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/cropnow/index.css" />
<script src="https://cdn.jsdelivr.net/npm/cropnow/index.js"></script>

Usage

import 'cropnow/index.css'
import Cropnow from 'cropnow'

Example

const container = document.getElementById('container')

const options = {
  url: 'example.jpg',                         // image url (required)
  preview?: document.getElementById('preview'), // Preview dom container (optional)
  onCropEnded?:({ canvas, data }) => {        // event fired when crop is ended (optional)
    console.log(canvas, data)
  }
}

const cropper = new Cropnow(container, options)

Methods

  • toPng(): void

download image as png.

  • toJpeg(): void

download image as jpeg.

  • getData(): object

Get the original size of image and current position of crop box.

  • getCanvas(): HTMLCanvasElement

Get a canvas element with cropped image drawn.

  • reset(): void

Reset crop box.

License

MIT

Keywords

FAQs

Last updated on 26 Aug 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc