eislambey/splathash-php
最新稳定版本:1.0.0
Composer 安装命令:
composer require eislambey/splathash-php
包简介
16 bytes fixed size image placeholder, an alternative to blurhash and thumbhash
README 文档
README
PHP port of SplatHash: compress any image to exactly 16 bytes and reconstruct a 32x32 RGBA placeholder.
Requirements
- PHP 8.2+
ext-gdforSplatHash::encode()from image files orGdImage
Install
composer require eislambey/splathash-php
Usage
<?php use Islambey\SplathashPhp\SplatHash; require __DIR__ . '/vendor/autoload.php'; $hash = SplatHash::encode('photo.jpg'); // 16 raw bytes $string = SplatHash::toBase64Url($hash); // 22-char base64url string $sameHash = SplatHash::fromBase64Url($string); $rgba = SplatHash::decode($sameHash); // 32 * 32 * 4 raw RGBA bytes
For already decoded pixels:
$hash = SplatHash::encodeRaw($rgbaBytes, $width, $height);
API
SplatHash::encode(string|GdImage $source): stringSplatHash::encodeRaw(string $rgba, int $width, int $height): stringSplatHash::decode(string $hash): stringSplatHash::toBase64Url(string $hash): stringSplatHash::fromBase64Url(string $value): string
Development
composer install php tests/run.php
License
MIT
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-01