IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    Progressive Image Loading - Blurry Placeholder Image like Unsplash

    Lynan发表于 2024-02-21 09:40:19
    love 0

    Unsplash is my favorite image site, not only for it’s huge amount of free images but also for it’s great user-experience. It has already been quite a while since Unsplash started using BlurHash to delivery progressive Image Loading experience.

    BlurHash added to photo objects

    The Concept

    Progressive Image Loading

    Progressive Image Loading makes better user experience. But what is Progressive Image Loading?

    Instead of waiting for the final image to be rendered, use a low-quality image as placeholder (LQIP) first, swith to the original one when it’s loaded.

    What is going on?

    1. Render an element (div for example) with specific aspect-ratio, usually the same as the original image
    2. Render a low-quality image first
    3. When this element is in viewport, triggers loading the original image
    4. After the original image is loaded, renders it upon the low-quality image and then hide/remove the low-quality image on the background

    Here’s an example:

    Placeholder vs. The Original

    ⬅️ This 8 × 8 px image can be scaled up many times (865 × 649 px on my screen for example) without increasing noticable noises.

    What does Unsplash do?

    1. Fetch list data using XHR
    2. Decode Blurhash from blur_hash field of a list item
    3. Generate a 8 x 8 px image/bmp image, rendered as image placeholder
    4. Render the original image when it’s loaded

    Why BMP?

    See Size Comparison. When canvas width is below 20px, image/png and image/bmp has almost the same size in comparison.

    Image Blurrer

    I created a web app (Image Blurrer) to generate blurry placeholder image. 4 types of output image supported:

    1. StackBlur
    2. Gaussian Blur
    3. Blurhash
    4. CSS Gradient

    Comparison

    In my personal usage and test, StackBlur is my favorite.

    Image Quality

    StackBlur
    Gaussian Blur
    Blurhash
    CSS Gradient

    Image Size

    Test Image: https://assets.lynan.cn/uPic/progress-image-loading-test-img.jpg

    width(px)jpegpngbmp
    4132 B90 B90 B
    6168 B135 B135 B
    8225 B198 B198 B
    10276 B279 B279 B
    12363 B378 B378 B
    14423 B495 B495 B
    16543 B630 B630 B
    18618 B783 B783 B
    20765 B954 B954 B
    22831 B1.1 KiB1.1 KiB
    241008 B1.3 KiB1.3 KiB
    261.1 KiB1.5 KiB1.5 KiB
    281.3 KiB1.8 KiB1.8 KiB
    301.4 KiB2.0 KiB2.0 KiB
    321.6 KiB2.3 KiB2.3 KiB

    Credit

    1. StackBlur
    2. Gaussian Blur
    3. Blurhash
    4. CSS Gradient


沪ICP备19023445号-2号
友情链接