CrossCopy / tauri-plugin-clipboard

A Tauri clipboard plugin with text, files, html, RTF, and image support. Clipboard content update monitoring is also supported.
https://crosscopy.github.io/tauri-plugin-clipboard/
MIT License
145 stars 10 forks source link

Improve clipboard image read performance #8

Closed HuakunShen closed 1 year ago

HuakunShen commented 1 year ago

Currently base64 is returned to frontend. For large image, this could be slow. I would like to include a readImageBinary method.

HuakunShen commented 1 year ago

Not sure if it's possible to reference a image file on disk, because reading bytes is still quite slow.

HuakunShen commented 1 year ago

I just found that reading large image to base64 and display was slow in dev mode. If I make a production build, it's actually quite fast.

Interestingly, in a production build, reading and displaying base64 image seems to be faster than reading bytes (array of int) and convert to Uint8Array then blob then object URL. The reason is probably: rust is a lot faster, and single-threaded JS got blocked during conversion.

Reading base64 seems to be the best option so far. I may still add the readImageBinary method for people who need it.

Further experiment is needed.