PHPackages                             badrshs/laravel-dynamic-image-composer - 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. [Templating &amp; Views](/categories/templating)
4. /
5. badrshs/laravel-dynamic-image-composer

ActiveLibrary[Templating &amp; Views](/categories/templating)

badrshs/laravel-dynamic-image-composer
======================================

Compose images dynamically from templates with text and image overlays

v1.1.2(5mo ago)013MITPHPPHP ^8.1|^8.2|^8.3|^8.4

Since Nov 15Pushed 5mo agoCompare

[ Source](https://github.com/badrshs/laravel-dynamic-image-composer)[ Packagist](https://packagist.org/packages/badrshs/laravel-dynamic-image-composer)[ RSS](/packages/badrshs-laravel-dynamic-image-composer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (10)Used By (0)

Laravel Dynamic Image Composer
==============================

[](#laravel-dynamic-image-composer)

Compose images dynamically from templates with text and image overlays. Perfect for generating certificates, badges, social media graphics, or any dynamic image content.

Features
--------

[](#features)

- 🎨 **Visual Designer Interface** - Drag-and-drop template designer with live preview
- 📝 Dynamic text overlays with custom fonts, colors, and positioning
- 🖼️ Image overlay support with opacity and positioning
- 🌍 Multi-language support (Arabic, English, and more)
- 📐 Flexible positioning (left, center, right alignment)
- 🎯 Template-based generation with database storage
- 🔧 Filament admin panel integration (optional)
- 💾 Multiple storage disk support
- ⚡ Simple, fluent API

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

[](#installation)

Install via Composer:

```
composer require badrshs/laravel-dynamic-image-composer
```

### Quick Install (Recommended)

[](#quick-install-recommended)

Run the install command which will publish config, migrations, views, and optionally fonts:

```
php artisan dynamic-image-composer:install --with-fonts
```

This command will:

- ✅ Publish configuration file
- ✅ Publish migrations
- ✅ Publish views
- ✅ Publish default fonts (with --with-fonts flag)
- ✅ Create necessary directories
- ✅ Run migrations (with confirmation)
- ✅ Create storage link

### Manual Installation

[](#manual-installation)

If you prefer manual installation:

```
php artisan vendor:publish --tag=dynamic-image-composer-config
php artisan vendor:publish --tag=dynamic-image-composer-migrations
php artisan vendor:publish --tag=dynamic-image-composer-views
php artisan vendor:publish --tag=dynamic-image-composer-fonts
php artisan migrate
php artisan storage:link
```

Quick Start
-----------

[](#quick-start)

### Visual Designer Interface

[](#visual-designer-interface)

The package includes a complete **drag-and-drop visual designer** for creating and editing templates:

1. Create a template via Filament or directly in the database
2. Click the **"Designer"** button on any template
3. Upload image elements (logos, stamps, decorations)
4. Drag and position elements on the canvas
5. Add text fields with positioning and styling
6. Preview your design in real-time
7. Generate the final composite image

**Accessing the Designer:**

```
// From Filament: Click "Designer" button on any template
// Or directly via route:
route('image-template.designer', ['template' => $templateId])
```

### Basic Usage

[](#basic-usage)

```
use Badrshs\DynamicImageComposer\DynamicImageComposer;

$composer = new DynamicImageComposer();

// Generate image with text overlays
$image = $composer->generate(
    templatePath: 'templates/my-template.png',
    fields: [
        'name' => [
            'value' => 'John Doe',
            'x' => 'center',
            'y' => 500,
            'fontSize' => 60,
            'color' => 'black',
            'font' => 'default',
            'alignment' => 'center'
        ],
        'date' => [
            'value' => date('Y-m-d'),
            'x' => 100,
            'y' => 1000,
            'fontSize' => 30,
            'color' => 'gray',
            'font' => 'default'
        ]
    ]
);

// Save to storage
$result = $composer->save($image, 'output-' . time() . '.png');
// Returns: ['path' => '...', 'url' => '...', 'filename' => '...', 'disk' => '...']

// Or output directly as HTTP response
return $composer->output($image, 'my-image.png');
```

### With Image Overlays

[](#with-image-overlays)

```
$image = $composer->generate('templates/base.png', [
    'title' => [
        'value' => 'Certificate of Achievement',
        'x' => 'center',
        'y' => 300,
        'fontSize' => 80,
        'color' => 'gold'
    ]
]);

// Add logo overlay
$composer->addOverlay($image, 'logos/company-logo.png', [
    'x' => 100,
    'y' => 100,
    'width' => 200,
    'height' => 200,
    'opacity' => 0.8
]);

return $composer->output($image);
```

### Using Database Templates

[](#using-database-templates)

```
use Badrshs\DynamicImageComposer\Models\ImageTemplate;

// Create a template
$template = ImageTemplate::create([
    'name' => 'My Certificate Template',
    'background_image' => 'templates/certificate-bg.png',
    'width' => 2480,
    'height' => 3508,
    'is_active' => true,
    'field_configuration' => [
        'fields' => [
            'name' => [
                'x' => 'center',
                'y' => 1200,
                'fontSize' => 100,
                'color' => 'black',
                'font' => 'monotype',
                'alignment' => 'center'
            ]
        ]
    ]
]);

// Generate from template
$composer = new DynamicImageComposer();
$image = $composer->generate(
    $template->background_image,
    array_merge(
        ['name' => ['value' => 'Jane Smith']],
        $template->field_configuration['fields'] ?? []
    )
);
```

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

[](#configuration)

Edit `config/dynamic-image-composer.php`:

```
return [
    // Storage disk for templates and generated images
    'disk' => env('DYNAMIC_IMAGE_DISK', 'public'),

    // Directories
    'templates_directory' => 'image-templates',
    'elements_directory' => 'image-elements',
    'generated_directory' => 'generated-images',
    'fonts_directory' => 'fonts',

    // Font definitions (add your custom fonts)
    'fonts' => [
        'default' => [
            'en' => 'Museo500-Regular.ttf',
            'ar' => 'sky.ttf',
        ],
        // Add more fonts...
    ],

    // Color definitions (RGB values)
    'colors' => [
        'black' => [40, 40, 40],
        'white' => [255, 255, 255],
        'gold' => [212, 175, 55],
        // Add more colors...
    ],
];
```

Field Configuration
-------------------

[](#field-configuration)

Each field supports these options:

OptionTypeDescriptionDefault`value`stringText to displayRequired`x`int|'center'X position or 'center'0`y`intY position0`fontSize`intFont size20`color`stringColor name from config'black'`font`stringFont name from config'default'`alignment`string'left', 'center', 'right''left'Filament Integration (Optional)
-------------------------------

[](#filament-integration-optional)

If you're using Filament, register the resource in your panel:

```
use Badrshs\DynamicImageComposer\Filament\Resources\ImageTemplateResource;

public function panel(Panel $panel): Panel
{
    return $panel
        ->resources([
            ImageTemplateResource::class,
        ]);
}
```

This provides a full admin interface for managing templates and elements, including:

- Template CRUD operations
- Visual designer interface
- Element management
- Live preview generation

Displaying Generated Images
---------------------------

[](#displaying-generated-images)

Use the included Blade component to display generated images in a grid:

```

```

Where `$generatedImages` is an array of:

```
[
    [
        'url' => 'https://...',
        'name' => 'John Doe',
        'filename' => 'certificate.png',
        'metadata' => 'Generated on 2024-01-01' // optional
    ],
    // ...
]
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom Fonts

[](#custom-fonts)

Add custom fonts to your `public/fonts` directory or storage, then register them in config:

```
'fonts' => [
    'my-font' => [
        'en' => 'MyFont-Regular.ttf',
        'ar' => 'MyFont-Arabic.ttf',
    ],
],
```

### Custom Colors

[](#custom-colors)

Add custom colors in config:

```
'colors' => [
    'brand-blue' => [30, 144, 255],
    'brand-red' => [220, 53, 69],
],
```

### Arabic Text Support

[](#arabic-text-support)

The package automatically detects and handles Arabic text:

```
$image = $composer->generate('template.png', [
    'name' => [
        'value' => 'محمد أحمد', // Arabic text
        'x' => 'center',
        'y' => 500,
        'fontSize' => 60,
        'font' => 'default', // Will use Arabic font variant
    ]
]);
```

Use Cases
---------

[](#use-cases)

- 📜 Certificates and diplomas
- 🏆 Achievement badges
- 🎫 Event tickets
- 📱 Social media graphics
- 🎴 ID cards and passes
- 📊 Dynamic reports with charts
- 🎨 Personalized marketing materials

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

[](#requirements)

- PHP 8.1 or higher
- Laravel 10.x, 11.x, or 12.x
- GD Library (enabled by default in most PHP installations)
- Default fonts included (Roboto for English, Noto Kufi Arabic for Arabic)

License
-------

[](#license)

MIT License. See LICENSE file for details.

Credits
-------

[](#credits)

Developed by Badr Shs

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance70

Regular maintenance activity

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

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

Every ~0 days

Total

9

Last Release

177d ago

### Community

Maintainers

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

---

Top Contributors

[![badrshs](https://avatars.githubusercontent.com/u/26596347?v=4)](https://github.com/badrshs "badrshs (15 commits)")

---

Tags

composerlaravelimagetemplatedynamicimage-generationtext-overlay

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/badrshs-laravel-dynamic-image-composer/health.svg)

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

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[brackets/admin-ui

Administration user interface template

29258.6k3](/packages/brackets-admin-ui)[sineld/bladeset

A very simple blade extension which allows variables to be set within blade templates.

4423.2k](/packages/sineld-bladeset)

PHPackages © 2026

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