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

Add function to export image (with Kaleido) as a b64 string #247

Closed
mchant opened this issue Nov 17, 2024 · 5 comments
Closed

Add function to export image (with Kaleido) as a b64 string #247

mchant opened this issue Nov 17, 2024 · 5 comments

Comments

@mchant
Copy link
Contributor

mchant commented Nov 17, 2024

Would it be useful if I create a PR for a to_b64 function? It's pretty much a copy of the write_image function, but returns a b64 string rather than write to a file.

@andrei-ng
Copy link
Collaborator

andrei-ng commented Nov 17, 2024

Hi @mchant ,

Isn't to_html or to_inline_html sufficient for this use-case?

@mchant
Copy link
Contributor Author

mchant commented Nov 17, 2024

Thanks for the reply, @andrei-ng. Those functions return html that makes a call to plotly. If someone just wants data for a picture, they can use this tag <img src="data:image/jpeg;base64,{b64_string_here}"> and pass in the string. This also returns a fairly consistent data length no matter how much data is used in the plot. In an HTTP API environment, this makes a more predictable load time because the data returned is not dependent on the length of x and y.

@andrei-ng
Copy link
Collaborator

Hi @mchant. Thanks for the clarification. Yes, please submit a PR and I will merge it in. If you need to use an external crate to achieve this, I think it is better to put it behind a feature flag.

@mchant mchant mentioned this issue Nov 17, 2024
@mchant
Copy link
Contributor Author

mchant commented Nov 22, 2024

Hi, @andrei-ng , it's in PR #251

@andrei-ng andrei-ng changed the title add a to_b64 function Add function to export image (with Kaleido) as a b64 string Nov 24, 2024
@andrei-ng
Copy link
Collaborator

closed by #251

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

2 participants