How to save an HTML5 Canvas as an image on a server?

后端 未结 8 2239
走了就别回头了
走了就别回头了 2020-11-21 23:50

I\'m working on a generative art project where I would like to allow users to save the resulting images from an algorithm. The general idea is:

  • Create an image
8条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-11-22 00:35

    In addition to Salvador Dali's answer:

    on the server side don't forget that the data comes in base64 string format. It's important because in some programming languages you need to explisitely say that this string should be regarded as bytes not simple Unicode string.

    Otherwise decoding won't work: the image will be saved but it will be an unreadable file.

提交回复
热议问题