jlaso / gd-wrapper
A GD wrapper
Installs: 33
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 1
pkg:composer/jlaso/gd-wrapper
Requires
- php: >=5.6
This package is auto-updated.
Last update: 2025-10-15 12:57:25 UTC
README
image wrapper for PHP GD image
I created this package with the only intention to write compact and understandable scripts.
The idea is to use this:
$image = new Image(800, 600);
$image
    ->createColor('black', new Color(['R' => 0, 'G' => 0, 'B' => 0]))
    ->createColor('white', new Color(['R' => 255, 'G' => 255, 'B' => 255]))
    ->setColor('black')
    ->fill()
    ->setColor('white')
    ->fill(new Ellipse(new Point(400, 300), 200, 150))
    ->setColor('black')
    ->fill(new Circle(new Point(400, 300), 100))
    ->setColor('white')
    ->fill(new Circle(new Point(400, 300), 30))
    ->saveAsPng('/tmp/eye.png');
Instead of this:
$image = imagecreate(800, 600);
$black = imagecolorallocate($image, 0, 0, 0); 
$white = imagecolorallocate($image, 255, 255, 255);
 
imagefill($image, 0, 0, $black);
 
imagefilledellipse($image, 400, 300, 200, 150, $white);
imagefilledellipse($image, 400, 300, 100, 100, $black);
imagefilledellipse($image, 400, 300, 30, 30, $white);
imagepng($image, '/tmp/eye.png');
Example to write ellipses and circles:
php sample-eye.php && open /tmp/eye.png
Example to write polygons:
php sample-penta.php && open /tmp/penta.png
Example to write text: take a look over sample-text.php
php sample-text.php && open /tmp/text.png
Example to use palette:
php sample-palette.php && open /tmp/palette.png
Internal palettes had been imported from Jam3/nice-color-palettes



