Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

php-blurhash

> 编程语言
Open source

Pure PHP implementation of Blurhash (https://github.com/woltapp/blurhash)

710 stars0 likes1 views
WebsiteGitHub

About

Pure PHP implementation of Blurhash (https://github.com/woltapp/blurhash)

php-blurhash

A pure PHP implementation of Blurhash. The API is stable, however the hashing function in either direction may not be.

Blurhash is an algorithm written by Dag Ågren for Wolt (woltapp/blurhash) that encodes an image into a short (~20-30 byte) ASCII string. When you decode the string back into an image, you get a gradient of colors that represent the original image. This can be useful for scenarios where you want an image placeholder before loading, or even to censor the contents of an image a la Mastodon.

Installation

bash
$ composer require kornrunner/blurhash

Usage

Encoding with GD

Encoding an image to blurhash expects two-dimensional array of colors of image pixels, sample code:

…

Decoding with JS / TS

For decoding of blurhash people will likely go for some other implementation (JavaScript/TypeScript). PHP decoder returns a pixel array that can be used to generate the image:

php
<?php

require_once 'vendor/autoload.php';

use kornrunner\Blurhash\Blurhash;

$blurhash = 'LEHV6nWB2yk8pyo0adR*.7kCMdnj';
$width    = 269;
$height   = 173;

$pixels = Blurhash::decode($blurhash, $width, $height);
$image  = imagecreatetruecolor($width, $height);
for ($y = 0; $y < $height; ++$y) {
    for ($x = 0; $x < $width; ++$x) {
        [$r, $g, $b] = $pixels[$y][$x];
        imagesetpixel($image, $x, $y, imagecolorallocate($image, $r, $g, $b));
    }
}
imagepng($image, 'blurhash.png');

Contributing

Issues, feature requests or improvements welcome!

Licence

This project is licensed under the MIT License.

Stargazing

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPblurhashphp

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言