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

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

alexjustesen/laravel-placehold-image
====================================

A Laravel package to generate placeholder images from placehold.co

v1.0.2(8mo ago)077MITPHPPHP ^8.2

Since Aug 14Pushed 8mo agoCompare

[ Source](https://github.com/alexjustesen/laravel-placehold-image)[ Packagist](https://packagist.org/packages/alexjustesen/laravel-placehold-image)[ Docs](https://github.com/alexjustesen/laravel-placehold-image)[ GitHub Sponsors](https://github.com/alexjustesen)[ RSS](/packages/alexjustesen-laravel-placehold-image/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (13)Versions (5)Used By (0)

🖼️ Laravel Placehold Image
==========================

[](#️-laravel-placehold-image)

A Laravel package to generate placeholder images from .

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

[](#installation)

You can install the package via composer:

```
composer require alexjustesen/laravel-placehold-image
```

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-placehold-image-config"
```

This is the contents of the published config file:

```
return [
    'defaults' => [
        'format' => 'png',
        'background_color' => null,
        'text_color' => null,
        'text' => null,
        'font' => null,
    ],
];
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

Generate a placeholder image URL:

```
use AlexJustesen\LaravelPlaceholdImage\Facades\PlaceholdImage;

// Generate a 300x200 image
$url = PlaceholdImage::generate(300, 200);
// Returns: https://placehold.co/300x200

// Generate a square 300x300 image
$url = PlaceholdImage::generate(300);
// Returns: https://placehold.co/300
```

### Customization Options

[](#customization-options)

You can customize the placeholder image with various options:

```
// With background color
$url = PlaceholdImage::generate(300, 200, ['background_color' => 'ff0000']);
// Returns: https://placehold.co/300x200/ff0000

// With background and text colors
$url = PlaceholdImage::generate(300, 200, [
    'background_color' => 'ff0000',
    'text_color' => '00ff00'
]);
// Returns: https://placehold.co/300x200/ff0000/00ff00

// With custom text
$url = PlaceholdImage::generate(300, 200, ['text' => 'Hello World']);
// Returns: https://placehold.co/300x200?text=Hello+World

// With different format
$url = PlaceholdImage::generate(300, 200, ['format' => 'jpg']);
// Returns: https://placehold.co/300x200.jpg
```

### Fluent Interface

[](#fluent-interface)

The package supports a fluent interface for method chaining:

```
$url = PlaceholdImage::format('jpg')
    ->backgroundColor('ff0000')
    ->textColor('ffffff')
    ->text('Custom Text')
    ->font('arial')
    ->generate(300, 200);
// Returns: https://placehold.co/300x200/ff0000/ffffff.jpg?text=Custom+Text&font=arial
```

### Downloading Images

[](#downloading-images)

You can download the image data directly:

```
// Download image data as string
$imageData = PlaceholdImage::download(300, 200);

// Save image to file
$success = PlaceholdImage::save('/path/to/image.png', 300, 200);
```

### Using Dependency Injection

[](#using-dependency-injection)

You can also inject the service directly:

```
use AlexJustesen\LaravelPlaceholdImage\PlaceholdImage;

class ImageController extends Controller
{
    public function view()
    {
        $url = PlaceholdImage::generate(300, 200);

        return response()->json(['url' => $url]);
    }
}
```

### Available Methods

[](#available-methods)

#### `generate(int $width, ?int $height = null, array $options = []): string`

[](#generateint-width-int-height--null-array-options---string)

Generates a placeholder image URL.

#### `download(int $width, ?int $height = null, array $options = []): string`

[](#downloadint-width-int-height--null-array-options---string)

Downloads the image data as a string.

#### `save(string $path, int $width, ?int $height = null, array $options = []): bool`

[](#savestring-path-int-width-int-height--null-array-options---bool)

Saves the image to a file path.

#### Fluent Methods

[](#fluent-methods)

- `format(string $format)` - Set format (png, jpg, jpeg, webp)
- `backgroundColor(string $color)` - Set background color (hex without #)
- `textColor(string $color)` - Set text color (hex without #)
- `text(string $text)` - Set custom text
- `font(string $font)` - Set font family

### Configuration

[](#configuration)

You can set default options in the config file that will be applied to all requests:

```
// config/placehold-image.php
return [
    'defaults' => [
        'format' => 'jpg',
        'background_color' => 'cccccc',
        'text_color' => '969696',
        'text' => null,
        'font' => 'arial',
    ],
];
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

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

[](#security-vulnerabilities)

Please review [our security policy](SECURITY.md) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Alex Justesen](https://github.com/alexjustesen)
- [All Contributors](https://github.com/alexjustesen/laravel-placehold-image/contributors)

License
-------

[](#license)

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

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance59

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

Total

3

Last Release

264d ago

PHP version history (2 changes)v1.0.0PHP ^8.3

v1.0.2PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/2214164c880af0c0f116a6fccbab39e813d9714134b7365441fa411ee519475d?d=identicon)[alexjustesen](/maintainers/alexjustesen)

---

Top Contributors

[![alexjustesen](https://avatars.githubusercontent.com/u/1144087?v=4)](https://github.com/alexjustesen "alexjustesen (3 commits)")

---

Tags

imagelaravelpackageplaceholdplaceholderlaravelimageplaceholderplacehold

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/alexjustesen-laravel-placehold-image/health.svg)

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

###  Alternatives

[joshembling/image-optimizer

Optimize your Filament images before they reach your database.

111145.4k12](/packages/joshembling-image-optimizer)[saasykit/laravel-open-graphy

An awesome open graph image (social cards) generator package for Laravel.

13057.0k](/packages/saasykit-laravel-open-graphy)[ace-of-aces/laravel-image-transform-url

Easy, URL-based image transformations inspired by Cloudflare Images.

1756.4k](/packages/ace-of-aces-laravel-image-transform-url)[danihidayatx/image-optimizer

Optimize your Filament images before they reach your database. Forked from joshembling/image-optimizer for Filament v4 &amp; v5 support.

254.4k](/packages/danihidayatx-image-optimizer)[johncarter/filament-focal-point-picker

An image focal point picker for Filament Admin.

4326.5k1](/packages/johncarter-filament-focal-point-picker)[ralphjsmit/laravel-glide

Auto-magically generate responsive images from static image files.

4719.6k5](/packages/ralphjsmit-laravel-glide)

PHPackages © 2026

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