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

Is it possible to generate an image instead of displaying it on the DOM? #5

Open
zolomatok opened this issue Oct 15, 2019 · 3 comments

Comments

@zolomatok
Copy link

I love that you created this lib!
I'd like to generate an image on the backend and send it to the user by email. Can that be done?

@kazuma1989
Copy link

You can with https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL.

const container = document.createElement("div");
QrCode.render(
  {
    text: "some text",
    radius: 0.5, // 0.0 to 0.5
    ecLevel: "H", // L, M, Q, H
    fill: "#536DFE", // foreground color
    background: null, // color or null for transparent
    size: 128 // in pixels
  },
  container
);

const canvas = container.firstChild;
const src = canvas.toDataURL();
// Send `src` to your users.

https://codepen.io/kazuma1989/pen/eYNWeYv

@eagle275
Copy link

And now please without the canvas element actually present ... I want JUST the dataURL / image-data ...

@everythingability
Copy link

everythingability commented Feb 2, 2024

Same. I'd like to use it in Google's AppScript.

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

4 participants