Export image with canvas

后端 未结 2 1115
独厮守ぢ
独厮守ぢ 2021-01-27 02:39

I\'m creating an application (based only on HTML, CSS and jQuery) where I will create an image based on layers (just a bunch of divs one above each other) and then I will need t

相关标签:
2条回答
  • 2021-01-27 03:14

    As far as I know, you cannot make the browser download a file it's generated itself.

    However, you can use the canvas element's Canvas.getDataURL() method. It returns the image data, as a base64 encoded PNG. You could upload this to your server with Ajax, have the server convert it to a normal PNG file again (or even another file type), and then have the client download the image from the server.

    I know it's a litte strange way around the problem, but should be easily done.

    0 讨论(0)
  • 2021-01-27 03:33
    canvas.toDataURL()
    

    also see:

    canvas.toBlob()
    
    0 讨论(0)
提交回复
热议问题