PHPackages                             jackson/pixelo - 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. jackson/pixelo

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

jackson/pixelo
==============

Generate dynamic profile placeholder images for Laravel applications

v1.0.0(1mo ago)01MITPHPPHP ^8.0

Since May 6Pushed 1mo agoCompare

[ Source](https://github.com/JacksonK52/Pixelo)[ Packagist](https://packagist.org/packages/jackson/pixelo)[ RSS](/packages/jackson-pixelo/feed)WikiDiscussions main Synced 1w ago

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

 [![Pixelo Logo](pixelo.png)](pixelo.png)

Pixelo — Laravel Avatar Generator
=================================

[](#pixelo--laravel-avatar-generator)

[![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![PHP](https://camo.githubusercontent.com/2f6f9af2e917cbf5786673e8e4ed8d0d9b29be6131327a992063e69136a93411/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e302532422d626c7565)](https://php.net)[![Laravel](https://camo.githubusercontent.com/93554d1ac44e7880097a6bd117e99f90c33ddf03dcf0a37f3047fa50b8aaa4d2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31302532422d726564)](https://laravel.com)

Generate dynamic, colorful profile placeholder images from any name string.
No external services, no heavy dependencies — just PHP's built-in GD extension.

---

Features
--------

[](#features)

- 🎨 **Deterministic colors** — same name always maps to the same color
- 🔤 **Smart initials** — extracts 1–4 initials from any name string
- 🔵 **Three shapes** — `circle`, `square`, `rounded`
- 📐 **Any size** — 16 px to 1024 px
- 🌐 **HTTP route** — use as a plain `` URL
- 🖼️ **Blade directives** — `@pixeloAvatar`, `@pixeloUrl`
- ⚡ **ETag caching** — proper `Cache-Control` + `ETag` headers
- 🎨 **Full color control** — override background + foreground per call
- 🧩 **Custom palette** — swap the default 18-color palette in config
- 0️⃣ **Zero extra dependencies** — GD only

---

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

[](#requirements)

PHP^8.0Laravel^10, ^11, ^12ext-gd\*---

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

[](#installation)

```
composer require jackson/pixelo
```

Laravel's package auto-discovery registers the service provider and `Pixelo` facade automatically.

Publish the config (optional):

```
php artisan vendor:publish --tag=pixelo-config
```

---

Usage
-----

[](#usage)

### Facade

[](#facade)

```
use pixelo\Facades\Pixelo;

// Embed in
$dataUri = Pixelo::make('Jackson Konjengbam')->toBase64();

// Laravel HTTP response (for controller actions)
return Pixelo::make('Jane Smith')->size(256)->shape('rounded')->toResponse();

// Save PNG to disk
Pixelo::make('Alice')->save(storage_path('app/public/avatars/alice.png'));

// Route URL via facade
$url = Pixelo::make('Bob')->url('Bob', ['size' => 64, 'shape' => 'circle']);

// Full chain — all options
$png = Pixelo::make('Bob')
    ->size(200)
    ->shape('circle')
    ->background('#1E88E5')
    ->color('#FFFFFF')
    ->fontSize(0.45)    // font size as fraction of image size
    ->bold(true)
    ->length(2)
    ->toPng();
```

### Helper functions

[](#helper-functions)

```
// Returns a data URI
$src = pixelo('Jackson Konjengbam');

// With options
$src = pixelo('Jane Smith', [
    'size'   => 64,
    'shape'  => 'rounded',
    'bg'     => '5E35B1',     // hex without #
    'fg'     => 'FFFFFF',
    'length' => 2,
    'bold'   => false,
]);

// Returns a route URL
$url = pixelo_url('Jackson Konjengbam', ['size' => 128, 'shape' => 'circle']);
```

### Blade templates

[](#blade-templates)

```
{{-- Data URI (inline, no HTTP request) --}}

{{-- Blade directive --}}

{{-- Route URL --}}

```

### HTTP endpoint

[](#http-endpoint)

```
GET /pixelo/avatar?name=Jackson+Konjengbam
GET /pixelo/avatar?name=Jane+Smith&size=256&shape=rounded
GET /pixelo/avatar?name=Bob&size=64&shape=square&bg=1E88E5&fg=FFFFFF
GET /pixelo/avatar?name=Alice&size=128&length=1

```

**Query parameters:**

ParameterTypeDefaultDescription`name`string`?`Name to extract initials from`size`integer`128`Image size in pixels (16–1024)`shape`string`circle``circle`, `square`, or `rounded``bg`stringautoBackground hex (without `#`)`fg`stringautoForeground/text hex (without `#`)`length`integer`2`Number of initials to render (1–4)---

API Reference
-------------

[](#api-reference)

All methods on `AvatarGenerator` are fluent (chainable). `make()` returns a fresh clone so the base instance is never mutated.

### Builder methods

[](#builder-methods)

MethodSignatureDescription`make``make(string $name): static`Set the name to generate initials from. Always call this first.`size``size(int $size): static`Image width/height in pixels. Clamped to 16–1024.`shape``shape(string $shape): static``'circle'`, `'square'`, or `'rounded'`. Throws on invalid value.`background``background(string $color): static`Background hex color (with or without `#`).`color``color(string $color): static`Foreground/text hex color (with or without `#`).`fontSize``fontSize(float $ratio): static`Font size as a fraction of image size (0.1–0.9). Default: `0.40`.`bold``bold(bool $bold = true): static`Whether to use a bold font weight. Default: `true`.`length``length(int $length): static`Number of initials to render (1–4). Default: `2`.### Output methods

[](#output-methods)

MethodReturnsDescription`toPng()``string`Raw PNG binary.`toBase64()``string`Data URI: `data:image/png;base64,…` — embed directly in ``.`toResponse()``Illuminate\Http\Response`Laravel HTTP response with `Content-Type: image/png` and caching headers.`save(string $path)``string`Write PNG to disk, returns the path.`url(string $name, array $options = [])``string`Build a URL to the built-in `pixelo.avatar` route.---

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

[](#configuration)

`config/pixelo.php` after publishing:

```
return [
    'size'         => 128,
    'shape'        => 'circle',      // circle | square | rounded
    'length'       => 2,
    'font_ratio'   => 0.40,          // font size as fraction of image size
    'bold'         => true,
    'route_prefix' => 'pixelo/avatar',

    // Override the color palette — [background_hex, foreground_hex]
    'palette' => null,
    // Example:
    // 'palette' => [
    //     ['#0F172A', '#38BDF8'],
    //     ['#064E3B', '#6EE7B7'],
    // ],
];
```

---

Custom font
-----------

[](#custom-font)

Drop any `.ttf` file into `src/Fonts/` and name it `Roboto-Bold.ttf` (or `NotoSans-Bold.ttf`).
Pixelo picks it up automatically. Without a custom font it falls back to GD's built-in bitmap font.

---

Patterns
--------

[](#patterns)

### User model accessor

[](#user-model-accessor)

```
// app/Models/User.php
public function getAvatarAttribute(): string
{
    return pixelo($this->name, ['size' => 128]);
}
```

### API resource

[](#api-resource)

```
// app/Http/Resources/UserResource.php
'avatar' => pixelo_url($this->name, ['size' => 64, 'shape' => 'circle']),
```

### Consistent per-user avatars (no storage)

[](#consistent-per-user-avatars-no-storage)

The color selection is purely deterministic — `nameToIndex()` hashes the name string to a stable palette index. The same name input always produces identical output. No database column or file storage needed.

---

Running Tests
-------------

[](#running-tests)

```
composer install
vendor/bin/phpunit
```

---

License
-------

[](#license)

MIT © Jackson K

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance93

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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

34d ago

### Community

Maintainers

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

---

Top Contributors

[![JacksonK52](https://avatars.githubusercontent.com/u/25763793?v=4)](https://github.com/JacksonK52 "JacksonK52 (1 commits)")

---

Tags

laravelimageprofileavatarplaceholder

### Embed Badge

![Health badge](/badges/jackson-pixelo/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[intervention/image-laravel

Laravel Integration of Intervention Image

1558.1M158](/packages/intervention-image-laravel)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

76318.2M110](/packages/laravel-mcp)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

506511.0k27](/packages/bkwld-croppa)[hasinhayder/tyro-dashboard

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

5222.7k](/packages/hasinhayder-tyro-dashboard)[laravel/surveyor

Static analysis tool for Laravel applications.

8390.3k12](/packages/laravel-surveyor)

PHPackages © 2026

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