patchkit-image-uploader

Open an image, scale and crop, and then upload


Keywords
react
License
GPL-3.0
Install
npm install patchkit-image-uploader@1.2.0

Documentation

Image Uploader

Open an image, scale and crop, and then upload.

screenshot.png

import ImageUploader from 'patchkit-image-uploader'
<ImageUploader ref="myImageInput" current="/img/pic1.jpg" onChange={onChange} />

When ready to read the image data (eg for uploading), use the canvasToPng function:

const canvas = this.refs.myImageInput.querySelector('canvas')
ImageInput.canvasToPng(canvas, function (err, buffer) {
  if (err) return cb(err)
  // buffer now contains png data
  // can do eg buffer.toString('base64')
})

Use the .less file:

@import "node_modules/patchkit-image-uploader/styles.less"