Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blur hash addition #1621

Open
Silfalion opened this issue Sep 13, 2021 · 3 comments
Open

Blur hash addition #1621

Silfalion opened this issue Sep 13, 2021 · 3 comments
Labels
product / storage Fixes and upgrades for the Appwrite Storage.

Comments

@Silfalion
Copy link

🚀 Feature

Not sure how useful this would be but the idea is to add a blur hashing feature to appwrite, through the sdks or to the core itself.

As pointed by Meldiron, this could be kinda bloating for appwrite since the current solution to use a function to generate the hash then adding into a document that's paired to a pic in the storage worker works perfectly fine.

Have you spent some time to check if this issue has been raised before?

Yes

Have you read the Code of Conduct?

Yes

Pitch

Honestly, not very sure it should but someone may have a special need or idea as to how it would be relevant.

The simplest case scenario is for loading data about a product and its picture. You load the data which contains the id to the pic in storage. The data would have the blur hash along with it to show a blur while we fetch the picture from appwrite.

And as pointed above this can easily be done with sdk librairies and cloud functions.

@eldadfux
Copy link
Member

My main concern is that this might be too opinionated, if someone don't need this feature the overhead of getting the hash might be a bit too much. Maybe a dedicate endpoint or param as part of /v1/storage/{fileId}/preview can do the trick.

Anyway, I think it would be cool to have a cloud function that can do this thing on file creation.

@Silfalion
Copy link
Author

Love the idea of integrating it to preview, it would fit nicely with the concept of editing photos, somehow.

Cloud functions are plenty enough for this though, especially since the used packages are already maintained by third parties it would be one less hassle to maintain for Appwrite.

On the other hand, the package wouldn't be that complex, I mean I don't see anything crazy that can be added to blur hash, is there?

@Meldiron
Copy link
Contributor

Meldiron commented May 9, 2022

I don't think this can be the official Appwrite Storage feature, as not all files are images, so not all files can have BlurHash. That would result in many files having blurhash value null. Also, creating blurhash can be pretty intensive work and might be a downside for projects that don't need it.

Previewing a file with a small resolution could do the trick in some cases, but I believe Blurhash is used to spend CPU power in order to reduce the required network. Considering 3G in the metro, even preview could take a few seconds to load, purely for HTTP connection establishment.

With that said, BlurHash exists to fill the content with blurry images instead of having skeleton loaders all over the place. This means you load BlurHash with content. In a real scenario, you would have a collection like articles with attribute like coverFileId.
My recommendation would be to have an Appwrite Function that would listen to an event of a new document created in this articles collection... This function would look at coverFileId attribute, get the file, do the calculation, and update the document, adding value to an attribute blurHash.
This way, if you load articles on front end, you automatically get BlurHash with your data. No need for a file request, no need for a preview request... That's the best usage of BlurHash that you can have. And of course, after rendering BlurHash, fire a request to get the file and replace BluHash as soon as you have the image file downloaded.

@stnguyen90 stnguyen90 added the product / storage Fixes and upgrades for the Appwrite Storage. label Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product / storage Fixes and upgrades for the Appwrite Storage.
Projects
None yet
Development

No branches or pull requests

4 participants