andrewgjohnson/imagegradientrectangle

imagegradientrectangle is a function that will draw a gradient filled rectangle on your PHP GD images

Maintainers

Package info

github.com/andrewgjohnson/imagegradientrectangle

Homepage

pkg:composer/andrewgjohnson/imagegradientrectangle

Fund package maintenance!

andrewgjohnson

Patreon

Statistics

Installs: 25

Dependents: 1

Suggesters: 0

Stars: 2

Open Issues: 0

v1.1.1 2026-05-14 22:50 UTC

This package is auto-updated.

Last update: 2026-05-14 22:56:21 UTC


README

MIT License Current Release Contributors Packagist Downloads Issues Patreon

Description

imagegradientrectangle is a function that will draw a gradient filled rectangle on your PHP GD images.

Patreon - Become a Patron

imagegradientrectangle is an agjgd project.

Usage

With Composer

This project offers support for the Composer dependency manager. You can find the imagegradientrectangle package online on packagist.org.

Install using Composer

Either run this command:

composer require andrewgjohnson/imagegradientrectangle

or add this to the require section of your composer.json file:

"andrewgjohnson/imagegradientrectangle": "1.*"

Without Composer

To use without Composer add an include to the imagegradientrectangle.php source file.

include_once 'source/imagegradientrectangle.php';

Dependencies

This project has external dependencies. If you use Composer you will not need to worry as dependencies are handled automatically. If you do not use Composer you will need to manage these dependencies yourself.

Dependencies List

Examples

$red  = imagecolorallocate($im, 0xFF, 0x00, 0x00);
$blue = imagecolorallocate($im, 0x00, 0x00, 0xFF);

// Standard method to draw solid filled rectangles
imagefilledrectangle($im, 10, 10, 100, 100, $red);
imagefilledrectangle($im, 10, 10, 100, 100, $blue);

// This will draw a red-to-blue gradient filled rectangle (vertical gradient)
imagegradientrectangle($im, 10, 10, 100, 100, $red, $blue);

// This will draw a red-to-blue gradient filled rectangle (horizontal gradient)
imagegradientrectangle($im, 10, 10, 100, 100, $red, $blue, true);

There are other examples included in the GitHub repository and on imagegradientrectangle.agjgd.org.

Help Requests

Please post any questions in the discussions area on GitHub if you need help.

If you discover a bug please enter an issue on GitHub. When submitting an issue please use our issue templates.

Contributing

Please read our contributing guidelines if you want to contribute.

You can contribute financially by becoming a patron at patreon.com/agjopensource to support imagegradientrectangle and other agjgd.org projects.

Patreon - Become a Patron

Acknowledgements

This project was started by Andrew G. Johnson (@andrewgjohnson).

Full list of contributors:

Our security policies and procedures come via the atomist/samples project. Our issue templates come via the tensorflow/tensorflow project. Our pull request template comes via the stevemao/github-issue-templates project. The mountains photo comes via Gabriel Garcia Marengo.

Changelog

You can find all notable changes in the changelog.