News for hackers. Stuff that matters.
Re:Blurhash: A compact representation of a placeholder for a... by nikeee on Friday November 04, 2022 @07:30AM (#33464941)
These blurry images look like they are composed of a couple of gradients.

Wouldn't it be possible to generate a tiny SVG or some CSS that reproduces these gradients?

In that case, basically no decoding step is needed and integration is as easy as setting a CSS style on a div or including an SVG. If the image dimensions are set from the start, the browser can even continue layouting the page before actually drawing the gradients. Letting the browser decode the gradients should also be much faster.

Is there a library that does that?

Re:Blurhash: A compact representation of a placeholder for a... by jesuscript on Friday November 04, 2022 @07:35AM (#33464977)
Someone can correct me, but gradients and large box shadows are some of the most intensive things your browser can render. There was noticeable slowdown when you do too much of that.
Re:Blurhash: A compact representation of a placeholder for a... by notpushkin on Friday November 04, 2022 @08:13AM (#33465292)
There certainly is an SVG thing but I don't remember the name.

I think Blurhash is the way it is because Wolt is an app and not a website, so the decoder is already loaded when you open it. For browser use, SVG would be more straightforward.

Re:Blurhash: A compact representation of a placeholder for a... by mark-r on Friday November 04, 2022 @12:06PM (#33468989)
SVG would be much larger for the same image, it's XML based.
Re:Blurhash: A compact representation of a placeholder for a... by SergeAx on Friday November 04, 2022 @01:23PM (#33470395)
It would be nice if there was a way to translate/transcode Blurhash directly to SVG with a small piece if TS code.
Re:Blurhash: A compact representation of a placeholder for a... by notpushkin on Friday November 04, 2022 @11:10PM (#33477445)
True, but we have GZip for that, and you don't need a lib to parse it. Actually, it would be nice to compare the overall size needed for both Blurhash lib + a bunch of hashes vs a bunch of SVG placeholders glued together.
Re:Blurhash: A compact representation of a placeholder for a... by wongarsu on Friday November 04, 2022 @08:31AM (#33465493)
At that point, why not just create a 6x3px thumbnail in a format of your choice and let interpolation take care of the gradients.
Re:Blurhash: A compact representation of a placeholder for a... by fold_left on Friday November 04, 2022 @08:58AM (#33465821)
I had a go at doing this in Rust some time ago https://github.com/JamieMason/blurhash-to-css and there is also https://plaiceholder.co/.
Re:Blurhash: A compact representation of a placeholder for a... by warpech on Friday November 04, 2022 @12:47PM (#33469738)
Nice!

A CSS Houdini worklet would be another way to represent this in CSS.

https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Houdini

https://houdini.how/

Re:Blurhash: A compact representation of a placeholder for a... by michaelmior on Friday November 04, 2022 @01:42PM (#33470799)
Interesting idea using Houdini, although I think browser support isn't really good enough yet to justify this.
Re:Blurhash: A compact representation of a placeholder for a... by wiredearp on Friday November 04, 2022 @03:28PM (#33472410)
Supposedly some library called SQIP might handle that as explained over on https://medium.com/free-code-camp/using-svg-as-placeholders-...