PHPackages                             aland20/image-layer-builder - 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. aland20/image-layer-builder

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

aland20/image-layer-builder
===========================

A simple package to add images and texts to a background

0.1.0(2y ago)013MITPHPPHP ^7.4 | ^8.0 | ^8.1 | ^8.2

Since Jul 1Pushed 2y ago1 watchersCompare

[ Source](https://github.com/AlanD20/image-layer-builder)[ Packagist](https://packagist.org/packages/aland20/image-layer-builder)[ Docs](https://github.com/aland20/image-layer-builder)[ RSS](/packages/aland20-image-layer-builder/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

Laravel Image Layer Builder
===========================

[](#laravel-image-layer-builder)

[![Latest Version on Packagist](https://camo.githubusercontent.com/39980350b19bf382a791563264a3061ff4a1937dd999df1f1b4ed9958d9a68b1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c616e6432302f696d6167652d6c617965722d6275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aland20/image-layer-builder)[![Total Downloads](https://camo.githubusercontent.com/1514d547a5073a02c4a55b8219843323066b6ce9bfeb94a29cb1482f72c35212/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c616e6432302f696d6167652d6c617965722d6275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aland20/image-layer-builder)

This package allows to merge small images onto a background, in addition to add texts to the background. Under the hood the package uses [`Intervention/v2/Image`](https://image.intervention.io/v2) to perform the generation.

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

[](#installation)

You can install the package via composer:

```
composer require aland20/image-layer-builder
```

- Publish config file

```
php artisan vendor:publish --provider="Aland20\ImageLayerBuilder\ImageLayerBuilderServiceProvider"
```

Usage
-----

[](#usage)

- **Note**: You have to set a custom font otherwise, you may not be able to use font size or other font properties.
- Checkout [`Intervention/v2/Image::text`](https://image.intervention.io/v2/api/text) for more information.
- You may want to customize the background and image resize as you desire.

```
use Illuminate\Http\Request;
use Aland20\ImageLayerBuilder\ImageLayerBuilder;

class ImageController extends Controller
{

    public function generate(Request $request)
    {
        $avatar = $request->file('avatar');
        $logo = $request->file('logo');
        $text = $request->text;

        $output = ImageLayerBuilder::make()
            // Set the background, it must be a valid full file name in the bgDirPath. Also, you may dynamically set it via requests.
            ->setBackground('my-custom-bg.png')
            // You may set the width and height for the background to resize. Default is 1200x750
            ->resizeBackgroundWidth(1000)
            ->resizeBackgroundHeight(750)
            // Add an image for the avatar, you may want to set the width and height resize,  positions, X-axis, Y-axis and many more as well.
            ->addImage($avatar, widthResize: 125, heightResize: 125, border: [3, '#fff'])
            // You may add more than one image on top of the background and change the position
            ->addImage($logo, rounded: false, position: 'bottom-right')
            // Add Text to the background, you may give some offset to get into the range
            ->addText('Welcome', position: 'bottom-center', offsetY: 25, angle: 25)
            // Add Text to the background, position starts from center
            ->addText($text, 'center', offsetY: -150)
            // Generate the instance
            ->generate();

        // Save to file
        $filename = $output->saveToFile();

        // Return raw stream data in string
        $rawStream = $output->getRawStream();

        return response($rawStream)->header('Content-type', 'image/png');
    }
}
```

- You may want to return all the available background to show it in frontend

```
use Aland20\ImageLayerBuilder;

$backgrounds = ImageLayerBuilder::make()->getBackgrounds();

foreach($backgrounds as $background):

    echo $background['path']; // background image file with extension
    echo $background['name']; // background image file without extension

endforeach;
```

### Available Public Methods

[](#available-public-methods)

```
   /**
     * Make a new instance statically, with default constructor values
     */
    public static function make(
        string $bgDirPath = '',
        string $outputPath = '',
        string $tempPath = ''
    ): static {}

  /**
   * Set background directory path to find all the available backgrounds.
   */
  public function setBgDirPath(string $bgDirPath): static {}

  /**
   * Set output directory path to store the output file.
   */
  public function setOutputPath(string $outputPath): static {}

  /**
   * Set temporary directory path to store temporary files.
   * This will be cleaned up after generation.
   */
  public function setTempPath(string $tempPath): static {}

  /**
   * Set the background width to resize.
   */
  public function resizeBackgroundWidth(int $width): static {}

  /**
   * Set the background heght to resize.
   */
  public function resizeBackgroundHeight(int $height): static {}

  /**
   * return all available background file names in the background types directory
   */
  public function getBackgrounds(): array {}

  /**
   * Set the background. This has to be an image that exists in the bigDirPath dir
   */
  public function setBackground(string $background): static {}

  /**
   * Set custom font path
   */
  public function setCustomFont(string $fontPath): static {}

  /**
   * Add an image on top of the background including X-axis and Y-axis positions from center
   * Available positions are: left, right, center, top, bottom, including top-left combinations
   * This can be called more than once.
   * Accepts the following data for the image image,
   * string - Path of the image in filesystem.
   * string - URL of an image (allow_url_fopen must be enabled).
   * string - Binary image data.
   * string - Data-URL encoded image data.
   * string - Base64 encoded image data.
   * resource - PHP resource of type gd. (when using GD driver)
   * object - Imagick instance (when using Imagick driver)
   * object - Intervention\Image\Image instance
   * object - SplFileInfo instance (To handle Laravel file uploads via Symfony\Component\HttpFoundation\File\UploadedFile)
   * The border is an array of [width, color]
   */
  public function addImage(
    mixed $image,
    int $widthResize = 175,
    int $heightResize = 175,
    bool $rounded = true,
    string $position = 'center',
    int $posX = 0,
    int $posY = 0
  ): static {}

  /**
   * Add given text with the options to the background image.
   * This method can be called more than once.
   */
  public function addText(
    string $text,
    string $position = 'top-center',
    int $offsetX = 0,
    int $offsetY = 0,
    int $fontSize = 32,
    string $color = '#fdf6e3',
    int $angle = 0
  ): static {

  /**
   * Generate background image
   */
  public function generate(): static {}

  /**
   * Exports the generated background image to a file with given format
   */
  public function saveToFile(?string $filename = ''): string

  /**
   * Return the background image stream content.
   */
  public function getOutputStream(): \GdImage {}

  /**
   * Return the background image stream content.
   */
  public function getRawStream(): string {}
```

### Changelog

[](#changelog)

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

Contributing
------------

[](#contributing)

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

License
-------

[](#license)

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

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

1052d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5a97e76b73bd58f1b881fc0e1b5642eb22626eace3e368f39099e7b82ff8a007?d=identicon)[aland20](/maintainers/aland20)

---

Top Contributors

[![AlanD20](https://avatars.githubusercontent.com/u/30084112?v=4)](https://github.com/AlanD20 "AlanD20 (2 commits)")

---

Tags

aland20image-layer-builder

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aland20-image-layer-builder/health.svg)

```
[![Health](https://phpackages.com/badges/aland20-image-layer-builder/health.svg)](https://phpackages.com/packages/aland20-image-layer-builder)
```

###  Alternatives

[intervention/image-laravel

Laravel Integration of Intervention Image

1496.5M102](/packages/intervention-image-laravel)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[devfactory/imagecache

Laravel package for generating thumbnails of images and caching them in your public files folder.

1620.3k](/packages/devfactory-imagecache)[spatie/laravel-og-image

Generate OG images for your Laravel app

305.2k](/packages/spatie-laravel-og-image)[freearhey/laravel-face-detection

A Laravel Package for Face Detection and Cropping in Images.

392.2k](/packages/freearhey-laravel-face-detection)[flowframe/laravel-drift

128.7k](/packages/flowframe-laravel-drift)

PHPackages © 2026

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