react-paint icon indicating copy to clipboard operation
react-paint copied to clipboard

How i can save image

Open namthang opened this issue 9 years ago • 1 comments

Hi author. Thanks so much for your sharing. I have a question: How i can save image or push image to an api or read image content. Thanks you.

namthang avatar Nov 29 '16 04:11 namthang

Try this: in father component, add a ref

<ReactPaint {...props} ref="paint" />

presume the father component have a button to saveImage:

<button onClick={this.saveImage}>Upload</button>

and the handler function

saveImage(){
    const dataUrl = this.refs.paint.canvas.toDataURL('image/png') // or .toBlob(callback)
    // then post the dataUrl
}

jieyou avatar Dec 26 '16 09:12 jieyou