{"id":19858097,"url":"https://github.com/tzsk/collage","last_synced_at":"2025-04-07T08:19:47.557Z","repository":{"id":25324761,"uuid":"103735431","full_name":"tzsk/collage","owner":"tzsk","description":"Generate Image Collage with PHP and Laravel","archived":false,"fork":false,"pushed_at":"2024-03-26T16:41:54.000Z","size":642,"stargazers_count":79,"open_issues_count":5,"forks_count":15,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-31T06:06:10.394Z","etag":null,"topics":["collage","collage-maker","composer","image","image-collage","image-processing","laravel","laravel-5-package","php","php-packages"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tzsk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"tzsk","custom":"https://paypal.me/KMAhmed"}},"created_at":"2017-09-16T07:51:11.000Z","updated_at":"2025-01-06T14:09:08.000Z","dependencies_parsed_at":"2024-06-19T20:01:55.699Z","dependency_job_id":null,"html_url":"https://github.com/tzsk/collage","commit_stats":{"total_commits":181,"total_committers":7,"mean_commits":"25.857142857142858","dds":"0.47513812154696133","last_synced_commit":"9129e490b529029f6c2e35fe9860b8b782bfd071"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tzsk%2Fcollage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tzsk%2Fcollage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tzsk%2Fcollage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tzsk%2Fcollage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tzsk","download_url":"https://codeload.github.com/tzsk/collage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247615385,"owners_count":20967184,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collage","collage-maker","composer","image","image-collage","image-processing","laravel","laravel-5-package","php","php-packages"],"created_at":"2024-11-12T14:21:20.364Z","updated_at":"2025-04-07T08:19:47.535Z","avatar_url":"https://github.com/tzsk.png","language":"PHP","readme":"# :gift: PHP Collage Maker\n\n![Collage Cover Image](resources/collage.svg)\n\n![GitHub License](https://img.shields.io/github/license/tzsk/collage?style=for-the-badge)\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/tzsk/collage.svg?style=for-the-badge\u0026logo=composer)](https://packagist.org/packages/tzsk/collage)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/tzsk/collage/tests.yml?branch=master\u0026label=tests\u0026style=for-the-badge\u0026logo=github)](https://github.com/tzsk/collage/actions?query=workflow%3ATests+branch%3Amaster)\n[![Total Downloads](https://img.shields.io/packagist/dt/tzsk/collage.svg?style=for-the-badge\u0026logo=laravel)](https://packagist.org/packages/tzsk/collage)\n\nCreate Image Collage with ease now with PHP. This package uses [`intervention/image`](https://github.com/Intervention/image) package to leverage image manipulation.\n\nUsing this package is very easy and creating Beautiful Collages are not tough anymore.\n\n\u003e _NOTE:_ Currently this package only supports 4 images. You can write your own generator to add 5 if you like.\n\n## :package: Installation\n\nThis is a composer package. So just run the below composer command inside your project directory to get it installed.\n\n```bash\ncomposer require tzsk/collage\n```\n\n## :gear: Configure\n\n\u003e If you are using this package outside laravel then you don't need to do this step.\n\n### config/app.php\n\n\u003e This package supports Package Auto-Discovery. And the latest version only supports Laravel \u003e= 7.x\n\nIf you want to use any other driver besides `'gd'` then you have to publish the configuration file:\n\n```bash\nphp artisan collage:publish\n```\n\nYou will then have a file in your config directory: `config/collage.php`\n\nIf you are using `'imagick'` then you can change it.\n\n## :fire: Usage\n\nFirst you need to have a set of images to make collage of. This package can except many kinds of Targets.\n\n```php\n$images = [\n    // List of images\n    'images/some-image.jpg',\n];\n```\n\nThere are other kinds of image targets supported:\n\n```php\n$images = [\n    // 1. File Contents\n    file_get_contents('some/image/path/or/url'),\n\n    // 2. Direct URLs\n    'https://some/image/url',\n\n    // 3. Absolute \u0026 Relative Path\n    '/some/image/somewhere/on/disk',\n\n    // 4. Intervention\\Image\\Image Object\n    ImageManagerStatic::make('...'),\n    // It's Intervention\\Image\\ImageManagerStatic\n\n    // 5. Or if you are Using Laravel\n    Image::make('...'),\n    // It's Intervention\\Image\\Facades\\Image\n];\n```\n\nDepending upon the number of images in the array this package will automatically use the right Generator.\n\n### :globe_with_meridians: Examples Outside Laravel\n\nFirstly, use the Class Namespace at the top.\n\n```php\nuse Tzsk\\Collage\\MakeCollage;\n\n$collage = new MakeCollage($driver); // Default: 'gd'\n```\n\n\u003e The Driver is either 'gd' or 'imagick'. Depending upon which library you are using with PHP. You can customize that. The default is `'gd'`.\n\n#### Create collage with 1 Image\n\nSupported, yes.\n\n```php\n$image = $collage-\u003emake(400, 400)-\u003efrom($images);\n\n// Add Padding:\n$image = $collage-\u003emake(400, 400)-\u003epadding(10)-\u003efrom($images);\n\n// Add Background Color:\n$image = $collage-\u003emake(400, 400)-\u003epadding(10)-\u003ebackground('#000')-\u003efrom($images);\n```\n\n#### Create collage with 2 images\n\n```php\n$image = $collage-\u003emake(400, 400)-\u003efrom($images); // Default Alignment: vertical\n\n// Change Alignment:\n$image = $collage-\u003emake(400, 400)-\u003efrom($images, function($alignment) {\n    $alignment-\u003evertical(); // Default, no need to have the Closure at all.\n    // OR...\n    $alignment-\u003ehorizontal();\n});\n```\n\n\u003e You can also add `padding()` and `background()` here.\n\n#### Create collage with 3 images\n\n```php\n$image = $collage-\u003emake(400, 400)-\u003efrom($images); // Default Alignment: twoTopOneBottom\n\n// Change Alignment:\n$image = $collage-\u003emake(400, 400)-\u003efrom($images, function($alignment) {\n    $alignment-\u003etwoTopOneBottom(); // Default, no need to have the Closure at all.\n    // OR...\n    $alignment-\u003eoneTopTwoBottom();\n    // OR...\n    $alignment-\u003eoneLeftTwoRight();\n    // OR...\n    $alignment-\u003etwoLeftOneRight();\n    // OR...\n    $alignment-\u003evertical();\n    // OR...\n    $alignment-\u003ehorizontal();\n});\n```\n\n\u003e You can also add `padding()` and `background()` here.\n\n#### Create collage with 4 images\n\n```php\n$image = $collage-\u003emake(400, 400)-\u003efrom($images); // Default Alignment: grid\n\n// Change Alignment:\n$image = $collage-\u003emake(400, 400)-\u003efrom($images, function($alignment) {\n    $alignment-\u003egrid(); // Default, no need to have the Closure at all.\n    // OR...\n    $alignment-\u003evertical();\n    // OR...\n    $alignment-\u003ehorizontal();\n});\n```\n\n\u003e You can also add `padding()` and `background()` here.\n\n### :heart_eyes: Examples in Laravel\n\nIn laravel you already have the Alias for the Collage Maker\n\n```php\nuse Tzsk\\Collage\\Facade\\Collage;\n\n$image = Collage::make(400, 400)-\u003efrom($images);\n```\n\nThe rest of the Features are same as when using in normal php.\n\n#### Create collage with 1 Image\n\n```php\n$image = Collage::make(400, 400)-\u003efrom($images);\n\n// Add Padding:\n$image = Collage::make(400, 400)-\u003epadding(10)-\u003efrom($images);\n\n// Add Background Color:\n$image = Collage::make(400, 400)-\u003epadding(10)-\u003ebackground('#000')-\u003efrom($images);\n```\n\n#### Create collage with 2 images\n\n```php\n$image = Collage::make(400, 400)-\u003efrom($images); // Default Alignment: vertical\n\n// Change Alignment:\n$image = Collage::make(400, 400)-\u003efrom($images, function($alignment) {\n    $alignment-\u003evertical(); // Default, no need to have the Closure at all.\n    // OR...\n    $alignment-\u003ehorizontal();\n});\n```\n\n\u003e You can also add `padding()` and `background()` here.\n\n#### Create collage with 3 images\n\n```php\n$image = Collage::make(400, 400)-\u003efrom($images); // Default Alignment: twoTopOneBottom\n\n// Change Alignment:\n$image = Collage::make(400, 400)-\u003efrom($images, function($alignment) {\n    $alignment-\u003etwoTopOneBottom(); // Default, no need to have the Closure at all.\n    // OR...\n    $alignment-\u003eoneTopTwoBottom();\n    // OR...\n    $alignment-\u003eoneLeftTwoRight();\n    // OR...\n    $alignment-\u003etwoLeftOneRight();\n    // OR...\n    $alignment-\u003evertical();\n    // OR...\n    $alignment-\u003ehorizontal();\n});\n```\n\n\u003e You can also add `padding()` and `background()` here.\n\n#### Create collage with 4 images\n\n```php\n$image = Collage::make(400, 400)-\u003efrom($images); // Default Alignment: grid\n\n// Change Alignment:\n$image = Collage::make(400, 400)-\u003efrom($images, function($alignment) {\n    $alignment-\u003egrid(); // Default, no need to have the Closure at all.\n    // OR...\n    $alignment-\u003evertical();\n    // OR...\n    $alignment-\u003ehorizontal();\n});\n```\n\n\u003e You can also add `padding()` and `background()` here.\n\n## :trophy: Return Value\n\nThe reaturned `$image` is the instance of `Intervention\\Image\\Image` object.\n\nYou can do multiple things with it.\n\n-   You can save the final collage.\n-   You can just use it as a plain response.\n-   You can crop/resize/colorize and more.\n\nRead more about what you can do in the [Official Documentation](http://image.intervention.io/).\n\n## :electric_plug: Create Custom Generators\n\nCreating a generator is very easy. Create a class that extends the abstract class: `Tzsk\\Collage\\Contracts\\CollageGenerator`.\n\n### Example:\n\n```php\nuse Tzsk\\Collage\\Contracts\\CollageGenerator;\n\nclass FiveImage extends CollageGenerator\n{\n    /**\n     * @param Closure $closure\n     * @return \\Intervention\\Image\\Image\n     */\n    public function create($closure = null)\n    {\n        // Your code to generate the Intervention\\Image\\Image object\n    }\n}\n```\n\n\u003e 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`.\n\n#### Extend outside laravel\n\n```php\n$image = $collage-\u003ewith([5 =\u003e Your\\Class\\Namespace\\FiveImage::class]);\n// Here the key is the number of file your generator accepts.\n// After this you can continue chaining methods like -\u003epadding()-\u003efrom() as usual.\n```\n\nYou can also override existing generators. Let's say you want to have the FourImage generator to behave differently.\nYou can make your own `MyFourImage` class and add it.\n\n```php\n$image = $collage-\u003ewith([4 =\u003e Your\\Class\\Namespace\\MyFourImage::class]);\n// It will replace the existing Generator with your own.\n// After this you can continue chaining methods like -\u003epadding()-\u003efrom() as usual.\n```\n\n#### Extend in laravel\n\n```php\n$image = Collage::with([5 =\u003e Your\\Class\\Namespace\\FiveImage::class]);\n// Here the key is the number of file your generator accepts.\n// After this you can continue chaining methods like -\u003epadding()-\u003efrom() as usual.\n```\n\nYou can also override existing generators. Let's say you want to have the FourImage generator to behave differently.\nYou can make your own `MyFourImage` class and add it.\n\n```php\n$image = Collage::with([4 =\u003e Your\\Class\\Namespace\\MyFourImage::class]);\n// It will replace the existing Generator with your own.\n// After this you can continue chaining methods like -\u003epadding()-\u003efrom() as usual.\n```\n\nYou can also do this from the `config/collage.php` config file.\n\nThere is a `generators` array which is currently empty. You can add your own generators there like below to Replace or add new generators.\n\n```php\n'generators' =\u003e [\n    // It will replace the current FourImage generator.\n    4 =\u003e Your\\Class\\Namespace\\MyFourImage::class,\n\n    // It will add a new generator.\n    5 =\u003e Your\\Class\\Namespace\\FiveImage::class,\n]\n```\n\n## :microscope: Testing\n\n```bash\ncomposer test\n```\n\n## :date: Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## :heart: Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## :lock: Security\n\nIf you discover any security related issues, please email mailtokmahmed@gmail.com instead of using the issue tracker.\n\n## :crown: Credits\n\n-   [Kazi Ahmed](https://github.com/tzsk)\n-   [All Contributors](../../contributors)\n\n## :policeman: License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","funding_links":["https://github.com/sponsors/tzsk","https://paypal.me/KMAhmed"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftzsk%2Fcollage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftzsk%2Fcollage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftzsk%2Fcollage/lists"}