@solakuroky/image-clipper

0.0.2 • Public • Published

image-clipper

image clipper

NPM version

Screenshot

install

npm install @solakuroky/image-clipper

Usage

var imageClipper = require('@solakuroky/image-clipper')

var clippedImage = imageClipper('https://someimage.png')

<script type="text/javascript">  
  function cropImage(source) {  
    var file = source.files[0]
    var clippedImage = imageClipper(file, {
        callback: callback
    })
  }
  function callback(canvas, resolve, reject) {
      resolve(canvas.toDataUrl())
  }
</script>  

<input type="file" name="file" onchange="cropImage(this)" />  

API

image-clipper

name type default description
image String|FileObject image to be clipped
options Object {} Configuration of clipper

options

name type default description
callback function(canvas, resolve, reject) Customize how to process image, default return a file
clipWidth Number 256 width to be clipped
clipHeight Number 256 height to be clipped
outlineWidth Number 32 shadow width around clipping window
okText String|ReactNode 'ok' text of the Ok button
cancelText String|ReactNode 'cancel' text of the Cancel button
okStyle Object {} style of the Ok button
cancelStyle Object {} style of the Cancel button
windowStyle Object {} style of the Cliper window

License

image-clipper is released under the MIT license.

Package Sidebar

Install

npm i @solakuroky/image-clipper

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

21.3 kB

Total Files

4

Last publish

Collaborators

  • solakuroky