How to save image from canvas with CSS filters

后端 未结 4 1681
失恋的感觉
失恋的感觉 2020-12-02 01:09

I need to save an image after using CSS filters on the client-side (without using a backend). What I have so far:

  1. Use CSS filters
  2. Co
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 01:39

    Your CSS properties are not actually applied to the canvas data. Think of the CSS as being another layer placed over the canvas element. You can implement your own image filters by using context.getImageData to get an array of raw RGBA values, then do your filter work and then write it back with context.putImageData. However, I think you really just want to save the output of the CSS filters. You may be able to do this using a tool like rasterizeHTML

提交回复
热议问题