TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

ThumbHash: A better compact image placeholder hash

768 pointsby summarityabout 2 years ago

28 comments

constexprabout 2 years ago
Hello! I made this. People are talking about not wanting pictures to be initially blurry before they finish loading. I understand that too, and I&#x27;m not sure how I feel about it myself (I could go either way).<p>But for what it&#x27;s worth, I actually made this for another use case: I have a grid of images that I want to be able to zoom really far out. It&#x27;d be nice to show something better than the average color when you do this, but it would be too expensive to fetch a lot of really small images all at once. ThumbHash is my way of showing something more accurate than a solid color but without the performance cost of fetching an image. In this scenario you&#x27;d only ever see the ThumbHash. You would have to zoom back in to see the full image.
评论 #35269419 未加载
评论 #35267384 未加载
评论 #35267586 未加载
评论 #35268451 未加载
评论 #35267476 未加载
评论 #35333904 未加载
jiggawattsabout 2 years ago
Blurring images or doing any sort of maths on the RGB values without first converting from the source-image gamma curve to &quot;linear light&quot; is wrong. Ideally, any such generated image should match the colour space of the image it is replacing. E.g.: sRGB should be used as the placeholder for sRGB, Display P3 for Display P3, etc...<p>Without these features, some images will have noticeable brightness or hue shifts. Shown side-by-side like in the demo page this is not easy to see, but when <i>replaced in the same spot</i> it will result in a sudden change. Since the whole point of this format is to replace images temporarily, then ideally this should be corrected.<p>As some people have said, developers often make things work for &quot;their machine&quot;. Their machine on the &quot;fast LAN&quot;, set to &quot;en-US&quot;, and for <i>their monitor</i> and web browser combination. Most developers use SDR sRGB and are blithely unaware that all iDevices (for example) use HDR Display P3 with different RGB primaries and gamma curves.<p>A hilarious example of this is seeing <i>Microsoft</i> use Macs to design UIs for Windows which then look too light because taking the same image file across to a PC shifts the brightness curve. Oops.
评论 #35267819 未加载
评论 #35268998 未加载
评论 #35267742 未加载
munroabout 2 years ago
I hate these blurry image thumbnails, much prefer some sort of hole, and just wait for a better thumbnail (look at youtube for this, or basically any site). I&#x27;d much rather see engineers spending more time making the thumbnails load faster (improving their backend throughput, precache thumbnails, better compression, etc). The blurry thumbnails have 2 issues 1) trick person into thinking they&#x27;re loaded, especially if there&#x27;s a flicker before the blurry thumbnails are displayed!!! so then the brain has to double back and look at the new image. 2) have a meaning that content is blocked from viewing
评论 #35267989 未加载
评论 #35266808 未加载
评论 #35269025 未加载
评论 #35272451 未加载
评论 #35267143 未加载
评论 #35267115 未加载
jjcmabout 2 years ago
FWIW, this is Evan Wallace, cofounder of Figma and creator of ESBuild. The dude has an incredible brain for performant web code.
评论 #35269581 未加载
transitivebsabout 2 years ago
I open sourced a version of what Evan calls the &quot;webp potato hash&quot; awhile back: <a href="https:&#x2F;&#x2F;github.com&#x2F;transitive-bullshit&#x2F;lqip-modern">https:&#x2F;&#x2F;github.com&#x2F;transitive-bullshit&#x2F;lqip-modern</a><p>I generally prefer using webp to BlurHash or this version of ThumbHash because it&#x27;s natively supported and decoded by browsers – as opposed to requiring custom decoding logic which will generally lock up the main thread.
评论 #35272405 未加载
评论 #35267877 未加载
emptyseaabout 2 years ago
What I’ve seen instagram and slack do is create a really small jpg and inline that in the API response. They then render it in the page and blur it while the full size image loads.<p>Placeholder image ends up being about 1KB vs the handful of bytes here but it looks pretty nice<p>Everything is a trade off of course, if you’re looking to keep data size to a minimum then blurhash or thumbhash are the way to go
评论 #35266638 未加载
评论 #35271513 未加载
评论 #35266779 未加载
canucker2016about 2 years ago
An order of magnitude smaller than Facebook&#x27;s 200 byte goal for preview photos in their graphql responses.<p>see <a href="https:&#x2F;&#x2F;engineering.fb.com&#x2F;2015&#x2F;08&#x2F;06&#x2F;android&#x2F;the-technology-behind-preview-photos&#x2F;" rel="nofollow">https:&#x2F;&#x2F;engineering.fb.com&#x2F;2015&#x2F;08&#x2F;06&#x2F;android&#x2F;the-technology...</a>
评论 #35272886 未加载
martin-adamsabout 2 years ago
This is nice, I really like it.<p>It reminds me of exploring the SVG loader using potrace to generate a silhouette outline of the image.<p>Here&#x27;s a demo of what that&#x27;s like:<p><a href="https:&#x2F;&#x2F;twitter.com&#x2F;Martin_Adams&#x2F;status&#x2F;918772434370748416?s=20" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;Martin_Adams&#x2F;status&#x2F;918772434370748416?s...</a>
评论 #35267371 未加载
Scaevolusabout 2 years ago
Nice! This would probably do even better if the color space was linear-- it should reduce how much the highlights (e.g. the sun) are lost.
a-dubabout 2 years ago
ThumbHash? seems more like MicroJPEG maybe? hash implies some specific things about the inputs and outputs that are definitely not true!<p>cool idea to extract one piece of the DCTs and emit a tiny low-res image though!
评论 #35268523 未加载
评论 #35268082 未加载
nawgzabout 2 years ago
On the examples given, it definitely looks the best of all of them, and seems to be as small as or smaller than their size<p>I&#x27;m not really sure I understand why all the others are presented in base83 though, while this uses binary&#x2F;base64. Is it because EvanW is smarter than these people or did they try to access some characteristic of base83 I don&#x27;t know about?
评论 #35266941 未加载
评论 #35266367 未加载
评论 #35266465 未加载
attah_about 2 years ago
Cool tech, but i feel that for all even remotely modern connection types placeholders like this are obsolete and do nothing but slow down showing the real thing.
评论 #35266825 未加载
评论 #35272203 未加载
评论 #35268024 未加载
评论 #35266839 未加载
评论 #35267085 未加载
jurimasaabout 2 years ago
This may be a super dumb question but... how is this better than using progressive jpegs?
评论 #35266803 未加载
评论 #35266778 未加载
评论 #35266832 未加载
评论 #35266734 未加载
IvanK_netabout 2 years ago
I think they should siply use four patches of BC1 (DXT1) texture: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;S3_Texture_Compression" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;S3_Texture_Compression</a><p>It allows storing a full 8x8 pixel image in 32 Bytes (4 bits per RGB pixel).
评论 #35269668 未加载
评论 #35276367 未加载
评论 #35268264 未加载
quechimbaabout 2 years ago
Very nice, I just saw the Ruby implementation[1]. This looks useful! Right now I&#x27;m making 16x16 PNGs and this looks way better. I might attempt making a custom element that renders these.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;daibhin&#x2F;thumbhash">https:&#x2F;&#x2F;github.com&#x2F;daibhin&#x2F;thumbhash</a>
hosejaabout 2 years ago
At <a href="https:&#x2F;&#x2F;www.mobilityengineeringtech.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.mobilityengineeringtech.com&#x2F;</a> the images are inline SVGs before they finish loading. Never seen that anywhere else.
评论 #35271974 未加载
detritesabout 2 years ago
Anyone know why the first comparison image is rotated 90 degrees for both ThumbHash and BlurHash versions? Is this a limitation of the type of encoding or just a mistake? All other comparison images match source rotation.
评论 #35267393 未加载
eisabout 2 years ago
The results are pretty impressive. I wonder if the general idea can be applied with a bit more data than the roughly 21 bytes in this version. I know it&#x27;s not a format that lends itself to be configurable. I&#x27;d be fine with placeholders that are say around 100-200 bytes. Many times that seems enough to actually let the brain roughly know what the image will contain.
kitsunesobaabout 2 years ago
I&#x27;m a big fan of anything that can make networked experiences a little smoother. When you&#x27;re having to deal with less than amazing connections pages full of loading spinners and blank spots get old fast.<p>Also, love that this comes with a reference implementation in Swift. Will definitely keep it in mind for future projects.
renewiltordabout 2 years ago
These are quite terrific. I really like these because I hate movement on page load. This one looks pretty good too.
TheRealPomaxabout 2 years ago
It looks like this has a bias for vertical banding that blurhash doesn&#x27;t have, is that intentional?
spankaleeabout 2 years ago
For these ultra-small sizes, I think I would go with Potato WebP since you can render it without JS, either with an &lt;img&gt; tag or a CSS background. I think it looks better too.
评论 #35267387 未加载
kamikaz1kabout 2 years ago
I don&#x27;t understand why it is only for &lt;100x100 images. Isn&#x27;t the blurring useful for larger images? what&#x27;s the point of inlining small ones?
评论 #35266937 未加载
clumsycomputerabout 2 years ago
love these type of optimizations... blurhash seems to be giving me more pleasant results that thumbhash on the few examples i ran through it! thumbhash seems to over emphasize&#x2F;crystalize parts of the image and results in a thumbnail that diverges from the source in unexpected ways.<p>either way this is awesome, and thanks for sharing
ed25519FUUUabout 2 years ago
First of all, I love the idea and I think it&#x27;s very creative.<p>As for my impression, but I don&#x27;t think the blurry images is impressive enough to load an additional 32 kB per image. I think the UX will be approximately the same with a 1x1 pixel image that&#x27;s just the average color used in the picture, but I can&#x27;t test that out.
评论 #35267106 未加载
评论 #35267107 未加载
评论 #35333914 未加载
评论 #35267099 未加载
mavciabout 2 years ago
I think Whatsapp also uses a similar method for sent pictures and videos.
MagicMoonlightabout 2 years ago
That’s impressively small
NoMoreBroabout 2 years ago
A single file with a few functions, it seemed a good test to convert it to some other languages with GPT-4 (I tried Python and Ruby). Unfortunately, my access to GPT-4 is limited to the 2k version, and the first function is 4,500 tokens (800 minified, but losing names, comments, and probably the quality of the conversion).<p>With some language-independent tests in such a repository, you might be able to semi-automatically convert the code into different languages, and continue with code scanning and optimizations.<p>Anyway: very nice work!