matrix-org / matrix-rust-sdk

Matrix Client-Server SDK for Rust
Apache License 2.0
1.26k stars 246 forks source link

[Media uploading] Generate blurhash for media uploads #1734

Open stefanceriu opened 1 year ago

stefanceriu commented 1 year ago

While certain media uploading preprocessing tasks are more easily done on the final client (e.g. video file thumbnail generation) the blurhash generation for images and thumbnails should be done rust side.

Hywan commented 1 year ago

Thanks for the issue.

Does it mean the Matrix Rust SDK should handle PDF, videos, images (incl. SVG) etc. All kind of formats… just to generate a blurhash? It also means the SDK should handle proprietary formats, I imagine some non-royalty-free video or image formats.

That's a lot of code, a lot of dependencies, that is probably duplicated with what the targeted platform can already offer for free, don't you think?

poljar commented 1 year ago

I think the MSC is limited to images only: https://github.com/matrix-org/matrix-spec-proposals/pull/2448.

stefanceriu commented 1 year ago

Sorry, this was only about images and thumbnails. I updated the description.

zecakeh commented 1 year ago

The issue currently is that there doesn't seem to be a well-maintained blurhash implementation in Rust. The "main" crate has not seen a release in 4 years and has had a few fixes since then that are not part of any release.

And there are a few other crates, none seem to stand out, and some are just forks of that crate to get the fixes in a release.

Hywan commented 1 year ago

We could use https://evanw.github.io/thumbhash/, which comes with a Rust implementation, https://github.com/evanw/thumbhash/tree/main/rust?

stefanceriu commented 1 year ago

I actually went with generating them on the client side as I already have the image loaded into memory following thumbnail generation.

Seeing as this is also questionable on your side I think best to just close this ticket.

zecakeh commented 1 year ago

Given that the Rust SDK allows to generate thumbnails for images, it would also be good if it generated a blurhash (or similar) in the process so the ticket can stay open imo.

jplatte commented 1 year ago

Yeah, I think it's just no longer relevant for EX and thus for Stefan anymore.