Chameleon: PHP image library
Chameleon (official website) is a PHP project I started in August 2017. It is a library wrapping the GD extension with an OOP layer (Object-oriented programming) and providing additional tools for image manipulation and creation.
As of January 2018, the following features are implemented:
- OOP wrapper to the GD extension
- Support for loading and creating TrueColor images with transparency
- Multiple color systems, choose the one which suits your needs: RGB, RGBA, HSL, HSLA, HSV, 6-digit Hex, 8-digit Hex
- Basic manipulation tasks: scaling, rotating, flipping and cropping
- Patterns for filling areas: Background color, RGB-Noise, Grid
- Configurable primitves with background pattern and borders (Rectangle)
- Draw rectangles with background patterns and borders
- Direct pixel manipulation
- GD image filters: Invert, Emboss, Brightness, Edgedetect, Smooth, Grayscale, Gaussian Blur, Selective Blur, Colorize, Contrast, Pixelate, Mean Removal
- Output formats: PNG, JPG and GIF
- Output to the browser, file streams or base64 encoded strings
- Gamma correction
- Loading images from base64-encoded strings
- Convolution matrices
- Drawing configurable of ellipses, circles, polygons and arcs
- Drawing characters and strings onto an image
- Layered images
The following example shows, what programming an image with Chameleon feels like. It creates a 800*600px image with RGBNoise as background and with two overlapping rectangles, each with a semi-transparent unicolor background and a black border.
This code results in the following image. Nothing beautiful, but it shows the
RGBAColor classes, the
BackgroundColor patterns, as well as the support for transparency.
The library is far away from being ready for production. Many features are still missing, while others need some rethinking. You can follow the development on GitHub. Once the library is ready, you can use it in your own projects via Composer.