PHPackages                             veyselaydogdu/laravel-base64-image - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. veyselaydogdu/laravel-base64-image

ActiveLibrary[File &amp; Storage](/categories/file-storage)

veyselaydogdu/laravel-base64-image
==================================

A powerful Laravel package for handling base64 encoded images with automatic resizing, validation, and storage management

v1.0.1(9mo ago)05MITPHPPHP ^8.0

Since Aug 8Pushed 9mo agoCompare

[ Source](https://github.com/veyselaydogdu/laravel-base64-image)[ Packagist](https://packagist.org/packages/veyselaydogdu/laravel-base64-image)[ Docs](https://github.com/veyselaydogdu/laravel-base64-image)[ RSS](/packages/veyselaydogdu-laravel-base64-image/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (3)Used By (0)

Laravel Base64 Image
====================

[](#laravel-base64-image)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e20ac67d94468fd104e1648e0cf41411e10bc7238659b37011ba4a40ddaff01c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f76657973656c6179646f6764752f6c61726176656c2d6261736536342d696d6167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/veyselaydogdu/laravel-base64-image)[![Total Downloads](https://camo.githubusercontent.com/5e519526d19599f1c42f6ae43b04d9173a8778cce8c5e9a39c7e5d6358b331bb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f76657973656c6179646f6764752f6c61726176656c2d6261736536342d696d6167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/veyselaydogdu/laravel-base64-image)[![GitHub Tests Action Status](https://camo.githubusercontent.com/f3babdc326a8a20254dcff339d780b5d00e3930d8636f38a329e1a1b8b2785dc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f76657973656c6179646f6764752f6c61726176656c2d6261736536342d696d6167652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/veyselaydogdu/laravel-base64-image/actions?query=workflow%3Arun-tests+branch%3Amain)[![License](https://camo.githubusercontent.com/e02c8dfe86173d892542a85b94cfc1b5052027c8d61488eedfdb139c1492de38/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f76657973656c6179646f6764752f6c61726176656c2d6261736536342d696d6167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/veyselaydogdu/laravel-base64-image)

A powerful Laravel package for handling base64 encoded images with automatic resizing, validation, and storage management. This package provides a simple and flexible way to save base64 encoded images to your Laravel application's storage system with advanced image processing capabilities.

Features
--------

[](#features)

- 🖼️ **Base64 Image Processing**: Convert and save base64 encoded images
- 🔄 **Image Resizing**: Automatic image resizing with aspect ratio control
- 📏 **Multiple Image Formats**: Support for JPG, PNG, WebP, GIF, BMP, and SVG
- 🛡️ **Validation**: Built-in file size and type validation
- 💾 **Flexible Storage**: Support for multiple Laravel storage disks
- 🎨 **Quality Control**: Adjustable image quality settings
- 🧭 **Auto Orientation**: Automatic image orientation based on EXIF data
- 🔧 **Configurable**: Highly configurable via configuration file
- ✅ **Well Tested**: Comprehensive test coverage
- 📚 **Laravel Integration**: Native Laravel service provider and facade

Requirements
------------

[](#requirements)

- PHP 8.0 or higher
- Laravel 9.0, 10.0, 11.0, or 12.0
- Intervention Image 3.0

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require veyselaydogdu/laravel-base64-image
```

The package will automatically register its service provider.

### Publish Configuration

[](#publish-configuration)

Publish the configuration file to customize the package settings:

```
php artisan vendor:publish --provider="VeyselAydogdu\LaravelBase64Image\Base64ImageServiceProvider" --tag="config"
```

This will create a `config/base64-image.php` file where you can customize the package settings.

Configuration
-------------

[](#configuration)

The configuration file allows you to customize various aspects of the package:

```
return [
    // Default storage disk
    'disk' => env('BASE64_IMAGE_DISK', 'public'),

    // Default upload location
    'location' => env('BASE64_IMAGE_LOCATION', 'uploads'),

    // Maximum file size in KB
    'max_size' => env('BASE64_IMAGE_MAX_SIZE', 5120), // 5MB

    // Supported image types
    'supported_types' => [
        'jpg', 'jpeg', 'png', 'webp', 'gif', 'bmp', 'svg'
    ],

    // Default image quality (1-100)
    'quality' => env('BASE64_IMAGE_QUALITY', 90),

    // Auto orient images based on EXIF data
    'auto_orient' => env('BASE64_IMAGE_AUTO_ORIENT', true),

    // Filename generation settings
    'filename' => [
        'length' => 45,
        'max_attempts' => 5,
    ],
];
```

### Environment Variables

[](#environment-variables)

You can set these environment variables in your `.env` file:

```
BASE64_IMAGE_DISK=public
BASE64_IMAGE_LOCATION=uploads
BASE64_IMAGE_MAX_SIZE=5120
BASE64_IMAGE_QUALITY=90
BASE64_IMAGE_AUTO_ORIENT=true
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use VeyselAydogdu\LaravelBase64Image\Facades\Base64Image;

// Save a base64 image
$result = Base64Image::save([
    'base64' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=='
]);

if ($result['success']) {
    echo "Image saved to: " . $result['path'];
    echo "Image URL: " . $result['url'];
}
```

### Advanced Usage

[](#advanced-usage)

```
use VeyselAydogdu\LaravelBase64Image\Facades\Base64Image;

// Save with custom parameters
$result = Base64Image::save([
    'base64' => $base64ImageData,
    'disk' => 'public',
    'location' => 'user-uploads',
    'filename' => 'profile-picture',
    'quality' => 85,
    'width' => 800,
    'height' => 600,
    'maintain_aspect_ratio' => true
]);
```

### Using the Manager Directly

[](#using-the-manager-directly)

```
use VeyselAydogdu\LaravelBase64Image\Base64ImageManager;

$manager = new Base64ImageManager();

$result = $manager->save([
    'base64' => $base64ImageData,
    // ... other parameters
]);
```

### Deleting Images

[](#deleting-images)

```
use VeyselAydogdu\LaravelBase64Image\Facades\Base64Image;

// Delete an image
$deleted = Base64Image::delete('uploads/image.jpg');

if ($deleted) {
    echo "Image deleted successfully";
}
```

### Response Structure

[](#response-structure)

The `save` method returns an array with the following structure:

```
[
    'success' => true,
    'path' => 'uploads/generated-filename.jpg',
    'filename' => 'generated-filename.jpg',
    'url' => 'https://your-app.com/storage/uploads/generated-filename.jpg',
    'size' => 15432, // Size in bytes
    'mime_type' => 'image/jpeg',
    'extension' => 'jpg',
    'dimensions' => [
        'width' => 800,
        'height' => 600
    ]
]
```

Available Parameters
--------------------

[](#available-parameters)

### Save Method Parameters

[](#save-method-parameters)

ParameterTypeDefaultDescription`base64`string**required**Base64 encoded image data`disk`string`config value`Storage disk to use`location`string`config value`Directory to save the image`filename`string`generated`Custom filename (without extension)`quality`int`config value`Image quality (1-100)`width`int`null`Target width for resizing`height`int`null`Target height for resizing`maintain_aspect_ratio`bool`true`Whether to maintain aspect ratio when resizingError Handling
--------------

[](#error-handling)

The package throws exceptions for various error conditions:

```
use VeyselAydogdu\LaravelBase64Image\Facades\Base64Image;

try {
    $result = Base64Image::save([
        'base64' => $invalidBase64Data
    ]);
} catch (\Exception $e) {
    // Handle the error
    echo "Error: " . $e->getMessage();
}
```

Common exceptions:

- `Base64 image data is required`
- `Invalid base64 image data`
- `Image size exceeds maximum allowed size`
- `Invalid image data`
- `Unsupported image type: {extension}`
- `Image processing failed: {reason}`
- `Failed to save image to storage`

Testing
-------

[](#testing)

Run the package tests:

```
composer test
```

Run tests with coverage:

```
composer test-coverage
```

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

If you discover a security vulnerability, please send an e-mail to Veysel Aydogdu via . All security vulnerabilities will be promptly addressed.

Credits
-------

[](#credits)

- [Veysel Aydogdu](https://github.com/veyselaydogdu)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

---

**Made with ❤️ by [Veysel Aydogdu](https://veyselaydogdu.com.tr)**

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance58

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

278d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d734b8c3e5f12c24c11d60ef7905f7712e68ad180552500510475058cab4b40a?d=identicon)[veyselaydogdu](/maintainers/veyselaydogdu)

---

Top Contributors

[![veyselaydogdu](https://avatars.githubusercontent.com/u/87179204?v=4)](https://github.com/veyselaydogdu "veyselaydogdu (10 commits)")

---

Tags

laravelimagebase64resizestorageuploadintervention

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/veyselaydogdu-laravel-base64-image/health.svg)

```
[![Health](https://phpackages.com/badges/veyselaydogdu-laravel-base64-image/health.svg)](https://phpackages.com/packages/veyselaydogdu-laravel-base64-image)
```

###  Alternatives

[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.3M74](/packages/unisharp-laravel-filemanager)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[contributte/image-storage

Image storage for Nette framework

28749.3k1](/packages/contributte-image-storage)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
