A very simple package for Laravel that calculates the BlurHash of images added via Spatie's Laravel Media Library, which you can then use as placeh older images.
In other words, you can show this as a placeholder:
...from an image like this:
More information:
You can install the package via composer:
composer require lukaswhite/media-blurhashIMPORTANT: Before running the migration, ensure you have run the media library package's migrations, as it adds a new column to the
mediatable.
Publish the migration:
php artisan vendor:publish --provider="Lukaswhite\MediaBlurhash\MediaBlurhashServiceProvider" --tag=migrationsRun the migration:
php artisan migrateOptionally publish the config:
php artisan vendor:publish --provider="Lukaswhite\MediaBlurhash\MediaBlurhashServiceProvider" --tag=configThis adds a blurhash column to the media table, which you can subsequently use to display a BlurHash, return in an API call etc.
By default, the package will calculate the BlurHash whenever an image is added via the media library. You can disable this in the config should you wish.
If you'd prefer to run the hashing process manually, you can either dispatch the package's job manually:
use Lukaswhite\MediaBlurhash\BlurhashMedia;
/** @var \Spatie\MediaLibrary\MediaCollections\Models\Media $media */
BlurhashMedia::dispatch($this->media);Or, to use the package configuration's queue connection and/or name:
use Lukaswhite\MediaBlurhash\Utils\Dispatcher;
/** @var \Spatie\MediaLibrary\MediaCollections\Models\Media $media */
(new Dispatcher($media))->run();You can tell the package to use a specific queue connection and/or name by publishing the config file and setting the appropriate values.
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email hello@lukaswhite.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.

