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

consider using thumbhash #8

Open
eikaramba opened this issue Apr 3, 2023 · 4 comments
Open

consider using thumbhash #8

eikaramba opened this issue Apr 3, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@eikaramba
Copy link

eikaramba commented Apr 3, 2023

see https://evanw.github.io/thumbhash/ for a better explanation. seems to generate better LQIPs(way better quality, same or lower file/base64 size) - not sure if imagetools library needs to implement this or you can hook this up directly here https://github.com/zerodevx/svelte-img/blob/master/src/lib/vite.js#L6

@zerodevx
Copy link
Owner

zerodevx commented Apr 4, 2023

Hey, that's an interesting idea. I experimented with blurhash before, and iirc there's a huge performance hit of run-time rendering of the hash representation, compared to the native rendering of a potato-webp LQIP background. Also requires javascript, while native does not. Drawback is the webp is up to double the byte size. Quality may be improved by applying a backdrop-filter like so: https://github.com/zerodevx/svelte-img#blurred-image-placeholders

not sure if imagetools library needs to implement this or you can hook this up directly here https://github.com/zerodevx/svelte-img/blob/master/src/lib/vite.js#L6

Yup I think we probably can hook it up directly.

Definitely still interested to look into this once I get a moment!

@zerodevx zerodevx added the enhancement New feature or request label Apr 4, 2023
@phoenisx
Copy link

Hi Folks

Thanks for this great library.
I was trying out a few scenarios using thumbhash, and comparing lqip generated by svelte-img.
I saw that the data URLs generated by thumbhash is way larger in size than svelte-img. Am I doing something wrong?? 🤔

I know the binary/base64 string generated by thumbhash is pretty small (under 30 bytes or so), but the data URL generated by it is significantly large in size.

How is lqip data URLs so small in size in this library? Is this because of using webp as format for data URLs, or because of the size used for lqip images, which is 16px, while in thumbhash examples it is 100px?

@zerodevx
Copy link
Owner

I know the binary/base64 string generated by thumbhash is pretty small (under 30 bytes or so), but the data URL generated by it is significantly large in size.

Hmm I don't really understand - thumbhash (and blurhash) images needs to be rendered at run-time i.e. browser needs to load the JS lib, decode the data string (in base64 usually around 30 chars), then render the image into the DOM. It can't be used like as an image data URI, unlike native image standards like jpg, webp etc.

@phoenisx
Copy link

Ohh!!
Thanks for helping me understand.
I thought generating data uri is required during the build to make it work.
Well generating base64 string during the build and processing it in the client makes more sense, and saves a lot of bytes 😅

Thanks for the quick response @zerodevx 🙇🏽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants