PHPackages                             net-tools/gd-indexed-color-converter - 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. net-tools/gd-indexed-color-converter

ActiveLibrary

net-tools/gd-indexed-color-converter
====================================

Composer library gd-indexed-color-converter

1.0.2(2y ago)0421MITPHP

Since May 16Pushed 2y agoCompare

[ Source](https://github.com/net-tools/gd-indexed-color-converter)[ Packagist](https://packagist.org/packages/net-tools/gd-indexed-color-converter)[ RSS](/packages/net-tools-gd-indexed-color-converter/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (4)Used By (1)

GDIndexedColorConverter
=======================

[](#gdindexedcolorconverter)

[GDIndexedColorConverter](https://github.com/ccpalettes/gd-indexed-color-converter) is a simple library that convert an image into [indexed color](http://en.wikipedia.org/wiki/Indexed_color)mode. With indexed color mode, an image can be displayed with only a few specific colors.

To archieve image dithering effect, GDIndexedColorConverter uses \[Floyd–Steinberg dithering\] ([http://en.wikipedia.org/wiki/Floyd%E2%80%93Steinberg\_dithering](http://en.wikipedia.org/wiki/Floyd%E2%80%93Steinberg_dithering)) algorithm to apply error diffusion of each pixel onto its neighboring pixels.

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

[](#requirements)

Since GDIndexedColorConverter uses some functions of the [GD extension](http://php.net/manual/en/book.image.php), you need to the enable GD extension in the PHP configuration file ([`php.ini`](http://php.net/manual/en/ini.php)).

Usage
-----

[](#usage)

GDIndexedColorConverter provide a function named `convertToIndexedColor` to convert an image into indexed color mode, it accepts three parameters(listed below), and return a new image resource of indexed color mode.

- `im` *(imageresource)* The image resource created by the functions of GD library.
- `palette` *(array)* The palette which contains all the specific colors that the indexed-color-mode image will use. This parameter is an array which stores all the colors, each color is an indexed array that consists of red, green and blue color channel values.
- `dither` *(float)* How much the Floyd–Steinberg dithering algorithm will affect the image. This parameter is optional, its default value is 0.75, and the value must be between 0 and 1.

**Code example:**

```
	// create an image
	$image = imagecreatefromjpeg('example.jpg');

	// create a gd indexed color converter
	$converter = new GDIndexedColorConverter();

	// the color palette
	$palette = array(
		array(0, 0, 0),
		array(255, 255, 255),
		array(255, 0, 0),
		array(0, 255, 0),
		array(0, 0, 255)
	);

	// convert the image to indexed color mode
	$new_image = $converter->convertToIndexedColor($image, $palette, 0.8);

	// save the new image
	imagepng($new_image, 'example_indexed_color.png', 0);
```

Dithers
-------

[](#dithers)

Applying different dither values on indexed-color images, you can get various image effects. In the `example` folder, there is a simple example that creates three indexed images with different dither values(0.2, 0.4, 0.8) and five colors(white, black, red, green and blue).

[![Example Output](https://raw.githubusercontent.com/ccpalettes/gd-indexed-color-converter/gh-pages/storage/example_output.jpg)](https://raw.githubusercontent.com/ccpalettes/gd-indexed-color-converter/gh-pages/storage/example_output.jpg)

The example image [`shell.jpg`](https://www.flickr.com/photos/sagesolar/10894165595) is created by [@sage\_solar](https://www.flickr.com/photos/sagesolar/). The image is under [Creative Commons License](https://creativecommons.org/licenses/by/2.0/).

License
-------

[](#license)

GDIndexedColorConverter is licensed under the \[MIT license\] ().

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.9% 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 ~522 days

Total

3

Last Release

780d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2cb0c1d404c8ae72b0a731246130079c2f440d6ea079815ca8c153aa361b1f28?d=identicon)[nettools.ovh](/maintainers/nettools.ovh)

---

Top Contributors

[![ccpalettes](https://avatars.githubusercontent.com/u/3355011?v=4)](https://github.com/ccpalettes "ccpalettes (10 commits)")[![net-tools](https://avatars.githubusercontent.com/u/6818724?v=4)](https://github.com/net-tools "net-tools (3 commits)")

### Embed Badge

![Health badge](/badges/net-tools-gd-indexed-color-converter/health.svg)

```
[![Health](https://phpackages.com/badges/net-tools-gd-indexed-color-converter/health.svg)](https://phpackages.com/packages/net-tools-gd-indexed-color-converter)
```

PHPackages © 2026

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