svenk/laravel-base64-images is a Laravel package for simply store base64 images in laravel.
It currently has 0 GitHub stars and 1 downloads on Packagist.
Install it with composer require svenk/laravel-base64-images.
Discover more Laravel packages by svenk
or browse all Laravel packages to compare alternatives.
Last updated
Simply store and delete base64 images in Laravel.
Install the package via Composer:
composer require svenk/laravel-base64-images
Publish the configuration file:
php artisan vendor:publish --tag=config
Add the service provider and alias (if not using package auto-discovery):
Open config/app.php and add the following to the providers array:
SvenK\LaravelBase64Images\Base64ImagesServiceProvider::class,
Add the following to the aliases array:
'Base64ImageHelper' => SvenK\LaravelBase64Images\Facades\Base64ImageHelper::class,
The configuration file config/base64images.php will be published to your application. You can customize the following settings:
return [
'scaling' => env('BASE64IMAGES_SCALING', null),
'quality' => env('BASE64IMAGES_QUALITY', 80),
];
scaling: The scaling factor for the images.quality: The quality of the webp images (0-100).To store a base64 encoded image:
use SvenK\LaravelBase64Images\Facades\Base64ImageHelper;
$base64Image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...'; // Your base64 encoded image string
$path = 'images'; // The directory where the image will be stored
$storedImagePath = Base64ImageHelper::store($base64Image, $path);
echo $storedImagePath; // Outputs the stored image path
To delete an image from storage:
use SvenK\LaravelBase64Images\Facades\Base64ImageHelper;
$imagePath = '/storage/images/your-image.webp';
$isDeleted = Base64ImageHelper::delete($imagePath);
if ($isDeleted) {
echo 'Image deleted successfully.';
} else {
echo 'Failed to delete image.';
}
This package provides a helper class to easily store and delete base64 encoded images in Laravel.
The helper class utilizes the Intervention Image package for image processing and Laravel's Storage facade for file storage operations.
This package is open-source software licensed under the MIT license.