PHPackages                             tzsk/collage - 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. [Image &amp; Media](/categories/media)
4. /
5. tzsk/collage

ActiveLibrary[Image &amp; Media](/categories/media)

tzsk/collage
============

Generate Image Collage with Laravel

7.0.0(3y ago)8162.2k↓44.5%15[5 PRs](https://github.com/tzsk/collage/pulls)MITPHPPHP ^8.0

Since Sep 16Pushed 2y ago3 watchersCompare

[ Source](https://github.com/tzsk/collage)[ Packagist](https://packagist.org/packages/tzsk/collage)[ Docs](https://github.com/tzsk/collage)[ Fund](https://paypal.me/KMAhmed)[ GitHub Sponsors](https://github.com/tzsk)[ RSS](/packages/tzsk-collage/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (7)Versions (20)Used By (0)

🎁 PHP Collage Maker
===================

[](#gift-php-collage-maker)

[![Collage Cover Image](resources/collage.svg)](resources/collage.svg)

[![GitHub License](https://camo.githubusercontent.com/519d0d6dc22708c57e4b0581db206ec161d6680039b482ca0f9321bba6ecfcf5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f747a736b2f636f6c6c6167653f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/519d0d6dc22708c57e4b0581db206ec161d6680039b482ca0f9321bba6ecfcf5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f747a736b2f636f6c6c6167653f7374796c653d666f722d7468652d6261646765)[![Latest Version on Packagist](https://camo.githubusercontent.com/a95484c675e39ee4e2f3b0a24f6a1198f447e7d67ef9faf6227627125e1e2a50/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f747a736b2f636f6c6c6167652e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d636f6d706f736572)](https://packagist.org/packages/tzsk/collage)[![GitHub Tests Action Status](https://camo.githubusercontent.com/850c5faf4de868b0a39d378602a8f6b2c169358afa7c0fb0294e24f691965447/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f747a736b2f636f6c6c6167652f74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666f722d7468652d6261646765266c6f676f3d676974687562)](https://github.com/tzsk/collage/actions?query=workflow%3ATests+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/53356f1d37b7a4e4783ae07ca50917fad9a618297b2c0bf253066675ac6ae01e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f747a736b2f636f6c6c6167652e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d6c61726176656c)](https://packagist.org/packages/tzsk/collage)

Create Image Collage with ease now with PHP. This package uses [`intervention/image`](https://github.com/Intervention/image) package to leverage image manipulation.

Using this package is very easy and creating Beautiful Collages are not tough anymore.

> *NOTE:* Currently this package only supports 4 images. You can write your own generator to add 5 if you like.

📦 Installation
--------------

[](#package-installation)

This is a composer package. So just run the below composer command inside your project directory to get it installed.

```
composer require tzsk/collage
```

⚙️ Configure
------------

[](#gear-configure)

> If you are using this package outside laravel then you don't need to do this step.

### config/app.php

[](#configappphp)

> This package supports Package Auto-Discovery. And the latest version only supports Laravel &gt;= 7.x

If you want to use any other driver besides `'gd'` then you have to publish the configuration file:

```
php artisan collage:publish
```

You will then have a file in your config directory: `config/collage.php`

If you are using `'imagick'` then you can change it.

🔥 Usage
-------

[](#fire-usage)

First you need to have a set of images to make collage of. This package can except many kinds of Targets.

```
$images = [
    // List of images
    'images/some-image.jpg',
];
```

There are other kinds of image targets supported:

```
$images = [
    // 1. File Contents
    file_get_contents('some/image/path/or/url'),

    // 2. Direct URLs
    'https://some/image/url',

    // 3. Absolute & Relative Path
    '/some/image/somewhere/on/disk',

    // 4. Intervention\Image\Image Object
    ImageManagerStatic::make('...'),
    // It's Intervention\Image\ImageManagerStatic

    // 5. Or if you are Using Laravel
    Image::make('...'),
    // It's Intervention\Image\Facades\Image
];
```

Depending upon the number of images in the array this package will automatically use the right Generator.

### 🌐 Examples Outside Laravel

[](#globe_with_meridians-examples-outside-laravel)

Firstly, use the Class Namespace at the top.

```
use Tzsk\Collage\MakeCollage;

$collage = new MakeCollage($driver); // Default: 'gd'
```

> The Driver is either 'gd' or 'imagick'. Depending upon which library you are using with PHP. You can customize that. The default is `'gd'`.

#### Create collage with 1 Image

[](#create-collage-with-1-image)

Supported, yes.

```
$image = $collage->make(400, 400)->from($images);

// Add Padding:
$image = $collage->make(400, 400)->padding(10)->from($images);

// Add Background Color:
$image = $collage->make(400, 400)->padding(10)->background('#000')->from($images);
```

#### Create collage with 2 images

[](#create-collage-with-2-images)

```
$image = $collage->make(400, 400)->from($images); // Default Alignment: vertical

// Change Alignment:
$image = $collage->make(400, 400)->from($images, function($alignment) {
    $alignment->vertical(); // Default, no need to have the Closure at all.
    // OR...
    $alignment->horizontal();
});
```

> You can also add `padding()` and `background()` here.

#### Create collage with 3 images

[](#create-collage-with-3-images)

```
$image = $collage->make(400, 400)->from($images); // Default Alignment: twoTopOneBottom

// Change Alignment:
$image = $collage->make(400, 400)->from($images, function($alignment) {
    $alignment->twoTopOneBottom(); // Default, no need to have the Closure at all.
    // OR...
    $alignment->oneTopTwoBottom();
    // OR...
    $alignment->oneLeftTwoRight();
    // OR...
    $alignment->twoLeftOneRight();
    // OR...
    $alignment->vertical();
    // OR...
    $alignment->horizontal();
});
```

> You can also add `padding()` and `background()` here.

#### Create collage with 4 images

[](#create-collage-with-4-images)

```
$image = $collage->make(400, 400)->from($images); // Default Alignment: grid

// Change Alignment:
$image = $collage->make(400, 400)->from($images, function($alignment) {
    $alignment->grid(); // Default, no need to have the Closure at all.
    // OR...
    $alignment->vertical();
    // OR...
    $alignment->horizontal();
});
```

> You can also add `padding()` and `background()` here.

### 😍 Examples in Laravel

[](#heart_eyes-examples-in-laravel)

In laravel you already have the Alias for the Collage Maker

```
use Tzsk\Collage\Facade\Collage;

$image = Collage::make(400, 400)->from($images);
```

The rest of the Features are same as when using in normal php.

#### Create collage with 1 Image

[](#create-collage-with-1-image-1)

```
$image = Collage::make(400, 400)->from($images);

// Add Padding:
$image = Collage::make(400, 400)->padding(10)->from($images);

// Add Background Color:
$image = Collage::make(400, 400)->padding(10)->background('#000')->from($images);
```

#### Create collage with 2 images

[](#create-collage-with-2-images-1)

```
$image = Collage::make(400, 400)->from($images); // Default Alignment: vertical

// Change Alignment:
$image = Collage::make(400, 400)->from($images, function($alignment) {
    $alignment->vertical(); // Default, no need to have the Closure at all.
    // OR...
    $alignment->horizontal();
});
```

> You can also add `padding()` and `background()` here.

#### Create collage with 3 images

[](#create-collage-with-3-images-1)

```
$image = Collage::make(400, 400)->from($images); // Default Alignment: twoTopOneBottom

// Change Alignment:
$image = Collage::make(400, 400)->from($images, function($alignment) {
    $alignment->twoTopOneBottom(); // Default, no need to have the Closure at all.
    // OR...
    $alignment->oneTopTwoBottom();
    // OR...
    $alignment->oneLeftTwoRight();
    // OR...
    $alignment->twoLeftOneRight();
    // OR...
    $alignment->vertical();
    // OR...
    $alignment->horizontal();
});
```

> You can also add `padding()` and `background()` here.

#### Create collage with 4 images

[](#create-collage-with-4-images-1)

```
$image = Collage::make(400, 400)->from($images); // Default Alignment: grid

// Change Alignment:
$image = Collage::make(400, 400)->from($images, function($alignment) {
    $alignment->grid(); // Default, no need to have the Closure at all.
    // OR...
    $alignment->vertical();
    // OR...
    $alignment->horizontal();
});
```

> You can also add `padding()` and `background()` here.

🏆 Return Value
--------------

[](#trophy-return-value)

The reaturned `$image` is the instance of `Intervention\Image\Image` object.

You can do multiple things with it.

- You can save the final collage.
- You can just use it as a plain response.
- You can crop/resize/colorize and more.

Read more about what you can do in the [Official Documentation](http://image.intervention.io/).

🔌 Create Custom Generators
--------------------------

[](#electric_plug-create-custom-generators)

Creating a generator is very easy. Create a class that extends the abstract class: `Tzsk\Collage\Contracts\CollageGenerator`.

### Example:

[](#example)

```
use Tzsk\Collage\Contracts\CollageGenerator;

class FiveImage extends CollageGenerator
{
    /**
     * @param Closure $closure
     * @return \Intervention\Image\Image
     */
    public function create($closure = null)
    {
        // Your code to generate the Intervention\Image\Image object
    }
}
```

> NOTE: Take a look at `src/Contracts/CollageGenerator.php` for details about all the things you have access to in the generator class. Also, if you need a reference consider looking into: `src/Generators/FourImage.php`.

#### Extend outside laravel

[](#extend-outside-laravel)

```
$image = $collage->with([5 => Your\Class\Namespace\FiveImage::class]);
// Here the key is the number of file your generator accepts.
// After this you can continue chaining methods like ->padding()->from() as usual.
```

You can also override existing generators. Let's say you want to have the FourImage generator to behave differently. You can make your own `MyFourImage` class and add it.

```
$image = $collage->with([4 => Your\Class\Namespace\MyFourImage::class]);
// It will replace the existing Generator with your own.
// After this you can continue chaining methods like ->padding()->from() as usual.
```

#### Extend in laravel

[](#extend-in-laravel)

```
$image = Collage::with([5 => Your\Class\Namespace\FiveImage::class]);
// Here the key is the number of file your generator accepts.
// After this you can continue chaining methods like ->padding()->from() as usual.
```

You can also override existing generators. Let's say you want to have the FourImage generator to behave differently. You can make your own `MyFourImage` class and add it.

```
$image = Collage::with([4 => Your\Class\Namespace\MyFourImage::class]);
// It will replace the existing Generator with your own.
// After this you can continue chaining methods like ->padding()->from() as usual.
```

You can also do this from the `config/collage.php` config file.

There is a `generators` array which is currently empty. You can add your own generators there like below to Replace or add new generators.

```
'generators' => [
    // It will replace the current FourImage generator.
    4 => Your\Class\Namespace\MyFourImage::class,

    // It will add a new generator.
    5 => Your\Class\Namespace\FiveImage::class,
]
```

🔬 Testing
---------

[](#microscope-testing)

```
composer test
```

📅 Changelog
-----------

[](#date-changelog)

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

❤️ Contributing
---------------

[](#heart-contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

🔒 Security
----------

[](#lock-security)

If you discover any security related issues, please email  instead of using the issue tracker.

👑 Credits
---------

[](#crown-credits)

- [Kazi Ahmed](https://github.com/tzsk)
- [All Contributors](../../contributors)

👮‍♂️ License
------------

[](#policeman-license)

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

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~146 days

Recently: every ~208 days

Total

15

Last Release

1154d ago

Major Versions

2.0.1 → 3.0.02019-09-25

3.0.0 → 4.0.02020-03-06

4.0.0 → 5.0.02020-09-13

5.1.1 → 6.0.02022-02-13

6.0.0 → 7.0.02023-05-06

PHP version history (6 changes)1.0.0PHP ~5.6|~7.0

3.0.0PHP ~7.2

4.0.0PHP ^7.2

5.0.0PHP ^7.4

5.1.0PHP ^7.4|^8.0

6.0.0PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/47768513?v=4)[Kazi Manzur Ahmed](/maintainers/kazimahmed)[@kazimahmed](https://github.com/kazimahmed)

---

Top Contributors

[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (95 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (65 commits)")[![tzsk](https://avatars.githubusercontent.com/u/13273787?v=4)](https://github.com/tzsk "tzsk (27 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![CihanAksoy](https://avatars.githubusercontent.com/u/1966483?v=4)](https://github.com/CihanAksoy "CihanAksoy (1 commits)")[![hyperplural](https://avatars.githubusercontent.com/u/33278849?v=4)](https://github.com/hyperplural "hyperplural (1 commits)")

---

Tags

collagecollage-makercomposerimageimage-collageimage-processinglaravellaravel-5-packagephpphp-packagestzskcollagephp collageimage collage phpcreate image collage laravellaravel image collage

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tzsk-collage/health.svg)

```
[![Health](https://phpackages.com/badges/tzsk-collage/health.svg)](https://phpackages.com/packages/tzsk-collage)
```

###  Alternatives

[intervention/image-laravel

Laravel Integration of Intervention Image

1588.9M181](/packages/intervention-image-laravel)[laravel-at/laravel-image-sanitize

A small but handy package to prevent malicious code execution coming into your application through uploaded image files.

33866.8k](/packages/laravel-at-laravel-image-sanitize)[erag/laravel-lang-sync-inertia

A powerful Laravel package for syncing and managing language translations across backend and Inertia.js (Vue/React/Svelte) frontends, offering effortless localization, auto-sync features, and smooth multi-language support for modern Laravel applications.

4925.3k](/packages/erag-laravel-lang-sync-inertia)[hasinhayder/tyro-dashboard

Tyro Dashboard - Beautiful admin dashboard for managing Tyro roles, privileges, users, and settings

5443.8k](/packages/hasinhayder-tyro-dashboard)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)

PHPackages © 2026

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