iamriajul / thumbhash-laravel
A PHP implementation of Thumbhash with Laravel integration.
Installs: 7 089
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- illuminate/support: ^9.0 || ^10.0 || ^11.0
- intervention/image: ^3.8
- srwiez/thumbhash: ^1.2
Requires (Dev)
- ergebnis/composer-normalize: ^2.30
- laravel/pint: ^1.5
- orchestra/testbench: ^6.27 || ^7.24 || ^8.3
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.6 || ^10.0
Suggests
- ext-gd: GD or Imagick is required.
- ext-imagick: GD or Imagick is required.
README
A PHP implementation of Thumbhash with Laravel integration.
Thumbhash is a compact representation of a placeholder for an image.
XFYJhIooaHh6d3hweYuHgHoJmA
⚠️ I highly recommend to have Imagick extension installed on your computer. GD extension has only 7 bits of alpha channel resolution, and 127 is transparent, 0 opaque. While the library will still work, you may have different image between platforms. See on stackoverflow
Supported Laravel Version
9.0 ~ 11.x
Installation
Install using composer
composer require iamriajul/thumbhash-laravel
Publish config file (Optional for )
php artisan vendor:publish --provider="Riajul\Thumbhash\ThumbhashServiceProvider"
Set up config file on config/thumbhash.php
Done!
Usage
Facade
Thumbhash::encode($file);
$file
can be any Intervention make method acceptable source.
app helper function
app('thumbhash') ->encode(request('file'));
TODO:
- Support decoding from thumbhash base64 string.
- Support encoding to thumbhash binary array.
- Support decoding from thumbhash binary array.
- Support encoding to dataURL.
License
Thumbhash is licensed under The MIT License (MIT).