Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cast image to base64 #15

Closed
dzfweb opened this issue Feb 22, 2017 · 3 comments
Closed

Cast image to base64 #15

dzfweb opened this issue Feb 22, 2017 · 3 comments

Comments

@dzfweb
Copy link

dzfweb commented Feb 22, 2017

How do i cast the drawabled image into base64 string?

@bradmartin
Copy link
Member

bradmartin commented Feb 22, 2017

Use the image-source modules fromNativeSource(image) method passing in the image from the promise result to get an image-source. Then use toBase64String method on the image-source instance.

import * as imageSourceModule from 'image-source';

drawingPad.getDrawing().then((res) => {        
          console.log(res);
          let x = imageSourceModule.fromNativeSource(res);
          let the64string = x.toBase64String("PNG");
       });  

Let me know if that helps 😄

@dzfweb
Copy link
Author

dzfweb commented Feb 22, 2017

Thank you.
It works.
👍

@dzfweb dzfweb closed this as completed Feb 22, 2017
@leocrawf leocrawf mentioned this issue Oct 13, 2018
@steve-79
Copy link

steve-79 commented Sep 9, 2020

Just in case anyone is banging their head on the wall - the above code by bradmartin worked for me on android perfectly, however iOS in Nativescript Vue needed the x.toBase64String("PNG") to be lowercase as such: x.toBase64String('png')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants