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

Saving Images

Open Alekos92 opened this issue 6 years ago • 5 comments

Hello and thanks for your work.

I would like to ask what is the suggested way of saving a drawn image, for example using a submit button.

Thank you.

Alekos92 avatar Apr 13 '19 22:04 Alekos92

I did this for another project I was working on, saved an html canvas to png. If it's not implemented yet I could c + p that code over in 2 weeks when I get back from vacation.

wmaillard avatar Apr 15 '19 12:04 wmaillard

Hi wmaillard, i would like to have the code if you may. Thanks in advance

zOthix avatar Sep 17 '19 18:09 zOthix

Hello.

You can check my project that allows you to identify drawn logos using Google's cognitive services: https://github.com/Alekos92/logo-identification-with-google

The functionality you are interested in can be found in the src/State.ts file.

Regards, Alex

Alekos92 avatar Sep 19 '19 09:09 Alekos92

Ability to save would be amazing

emptycrown avatar Feb 04 '20 23:02 emptycrown

This helped me to save my image.

Ref to sketch component:

        <SketchField
          tool={checkFillFigures}
          lineColor={drawerParams.color}
          lineWidth={drawerParams.strokeWidth}
          ref={(view) => {
            imageCaptureRef = view
          }}
          fillColor={checkFillColor}
        />

And call of undocumented component method:

      const result = await viewRef.toDataURL({
        format: 'base64',
        quality: 0.5,
        width: 480,
        height: 320,
      })
      setRequestImage(result.substring(22))
      // setRequestImage(result.replace('data:image/png;base64,',''))

AnatolyMakarovKHM avatar Jan 29 '21 13:01 AnatolyMakarovKHM