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

How do I download the images I add to the canvas #18

Closed
Fortune-Muhumuza opened this issue Aug 21, 2022 · 3 comments
Closed

How do I download the images I add to the canvas #18

Fortune-Muhumuza opened this issue Aug 21, 2022 · 3 comments

Comments

@Fortune-Muhumuza
Copy link

I'd like to create a function that when called creates an image file that I can save or download and be able to load for later use

@jakesteelman
Copy link

You can call the canvas instance's toDataURL method and pass in some options for the download. There may be a more efficient/easier way to do this, but I just create an anchor on the DOM, set the href and download attributes, call the click() method on it, then remove it with the remove() method. Hope this helps!

const url = editor?.canvas.toDataURL({ format: 'png' })
const dl = document.createElement('a')
dl.href = url
dl.dowload = 'filename'
dl.click()
dl.remove()

@asotog
Copy link
Owner

asotog commented Aug 25, 2022

yeah you can access fabricjs canvas from editor object, if you need to follow official documentation http://fabricjs.com/

@asotog
Copy link
Owner

asotog commented Nov 22, 2022

closing due inactivity

@asotog asotog closed this as completed Nov 22, 2022
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