PHPackages                             dotxdd/coloring-book - 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. dotxdd/coloring-book

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

dotxdd/coloring-book
====================

PHP library for generating coloring book pages from images

1.0.4(1y ago)14MITPHPPHP &gt;=8.2

Since Jun 29Pushed 1y agoCompare

[ Source](https://github.com/dotxdd/coloring-book)[ Packagist](https://packagist.org/packages/dotxdd/coloring-book)[ RSS](/packages/dotxdd-coloring-book/feed)WikiDiscussions main Synced today

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

Coloring Book Generator
=======================

[](#coloring-book-generator)

PHP library for generating coloring book pages from images.

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

[](#installation)

```
composer require dotxdd/coloring-book
```

Basic Usage
-----------

[](#basic-usage)

```
use Dotxdd\ColoringBook\ColoringBookGenerator;

$generator = new ColoringBookGenerator();
$result = $generator->generate('input.jpg', 'output.png');

if ($result) {
    echo "Coloring book generated successfully!";
}
```

Advanced Usage
--------------

[](#advanced-usage)

### Laravel Console Command Example

[](#laravel-console-command-example)

Here's how to use the library in a Laravel console command with advanced configuration:

```
use Dotxdd\ColoringBook\ColoringBookGenerator;

class GenerateColoringBook extends Command
{
    protected $signature = 'coloring:generate
                            {--input=test.jpg : Input image filename}
                            {--output=coloring_book.png : Output coloring book filename}
                            {--colors-json=colors.json : Output colors JSON filename}
                            {--threshold=30 : Contour detection threshold (1-100)}
                            {--colors=30 : Maximum number of colors (10-50)}
                            {--blur=4 : Blur radius}
                            {--minarea=0.015 : Minimum area percent for merging (e.g. 0.015 = 1.5%)}';

    public function handle()
    {
        $inputFile = $this->option('input');
        $outputFile = $this->option('output');
        $colorsJsonFile = $this->option('colors-json');

        $threshold = (int) $this->option('threshold');
        $maxColors = (int) $this->option('colors');
        $blur = (int) $this->option('blur');
        $minAreaPercent = (float) $this->option('minarea');

        $generator = new ColoringBookGenerator();
        $generator->setContourThreshold($threshold)
                  ->setMaxColors($maxColors)
                  ->loadImage($inputFile);

        // Generate coloring book with advanced settings
        $image = $generator->generateChildFriendlyColoringBook($maxColors, $blur, $minAreaPercent);

        // Save the generated image
        $result = $image->save($outputFile);

        // Save color palette as JSON
        $generator->saveColorPalette($colorsJsonFile);

        if ($result) {
            echo "Coloring book generated successfully!";
        }
    }
}
```

### Command Line Usage

[](#command-line-usage)

```
# Basic usage with default settings
php artisan coloring:generate --input=photo.jpg --output=coloring.png

# Advanced usage with custom parameters
php artisan coloring:generate \
    --input=photo.jpg \
    --output=coloring.png \
    --colors-json=palette.json \
    --threshold=25 \
    --colors=20 \
    --blur=3 \
    --minarea=0.02
```

### Configuration Parameters

[](#configuration-parameters)

ParameterDefaultRangeDescription`threshold`301-100Contour detection sensitivity`colors`3010-50Maximum number of colors to extract`blur`41-10Blur radius for smoothing`minarea`0.0150.001-0.1Minimum area percentage for merging regions### Output Files

[](#output-files)

The library generates two types of output files:

1. **Image file** (PNG) - The coloring book page with outlines
2. **JSON file** - Color palette with RGB values for each region

Example JSON output:

```
{
    "colors": [
        {"r": 255, "g": 0, "b": 0, "area": 0.15},
        {"r": 0, "g": 255, "b": 0, "area": 0.25},
        {"r": 0, "g": 0, "b": 255, "area": 0.10}
    ]
}
```

Features
--------

[](#features)

- Convert any image to a coloring book page
- Edge detection and outline generation
- Support for various image formats (JPG, PNG, GIF)
- Customizable output settings
- High-quality output suitable for printing
- Color palette extraction and export
- Advanced contour detection with adjustable threshold
- Region merging with configurable minimum area
- Blur and smoothing options for better results

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

[](#requirements)

- PHP 8.2 or higher
- GD extension enabled

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

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

[](#contributing)

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for a list of changes.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance49

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

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

Total

2

Last Release

369d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/88377577?v=4)[Gabriel Moskwa](/maintainers/Dotxdd)[@dotxdd](https://github.com/dotxdd)

---

Top Contributors

[![dotxdd](https://avatars.githubusercontent.com/u/88377577?v=4)](https://github.com/dotxdd "dotxdd (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dotxdd-coloring-book/health.svg)

```
[![Health](https://phpackages.com/badges/dotxdd-coloring-book/health.svg)](https://phpackages.com/packages/dotxdd-coloring-book)
```

###  Alternatives

[league/glide

Wonderfully easy on-demand image manipulation library with an HTTP based API.

2.6k53.3M146](/packages/league-glide)[intervention/image-laravel

Laravel Integration of Intervention Image

1588.9M183](/packages/intervention-image-laravel)[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

506516.3k29](/packages/bkwld-croppa)[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)[october/rain

October Rain Library

1601.7M83](/packages/october-rain)

PHPackages © 2026

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