@lemonneko/crop-empty-pixels
TypeScript icon, indicating that this package has built-in type declarations

0.1.0-rc.4 • Public • Published

Crop empty pixels

This package is ONLY for browsers

Usage

import cropImg from 'crop-empty-pixels'

// load a image
const img = document.createElement('img')
img.src = '/path/to/an/image/with/empty/border'
img.addEventListener('load', () => {
   // draw it on canvas once load
   const canvas = document.createElement('canvas')
   const canvasCtx = canvas.getContext('2d')!
   canvasCtx.drawImage(img)
   // pass the canvas to function then get new canvas
   const cropped = cropImg(canvas)
   // set cropped image data to origin
   img.src = cropped.toDataURL()
}, { once: true })

Readme

Keywords

none

Package Sidebar

Install

npm i @lemonneko/crop-empty-pixels

Weekly Downloads

1

Version

0.1.0-rc.4

License

none

Unpacked Size

3.14 kB

Total Files

5

Last publish

Collaborators

  • lemon_neko