https://github.com/andrewgjohnson/imagecolorallocatefromstring
imagecolorallocatefromstring is a function that will allocate a color based on a string for your PHP GD images.
https://github.com/andrewgjohnson/imagecolorallocatefromstring
composer gd graphics image images php
Last synced: 28 days ago
JSON representation
imagecolorallocatefromstring is a function that will allocate a color based on a string for your PHP GD images.
- Host: GitHub
- URL: https://github.com/andrewgjohnson/imagecolorallocatefromstring
- Owner: andrewgjohnson
- License: mit
- Created: 2018-12-09T00:15:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-18T18:59:53.000Z (almost 2 years ago)
- Last Synced: 2025-04-15T21:55:43.939Z (about 1 year ago)
- Topics: composer, gd, graphics, image, images, php
- Language: PHP
- Homepage: https://imagecolorallocatefromstring.agjgd.org
- Size: 1.72 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: .github/SECURITY.md
- Support: .github/SUPPORT.md
Awesome Lists containing this project
README
# imagecolorallocatefromstring
[](https://github.com/andrewgjohnson/imagecolorallocatefromstring/blob/master/LICENSE)
[](https://github.com/andrewgjohnson/imagecolorallocatefromstring/releases)
[](https://github.com/andrewgjohnson/imagecolorallocatefromstring/graphs/contributors)
[](https://packagist.org/packages/andrewgjohnson/imagecolorallocatefromstring/stats)
[](https://github.com/andrewgjohnson/imagecolorallocatefromstring/issues)
[](https://patreon.com/agjopensource)
## Description
**imagecolorallocatefromstring** is a function that will allocate a color based on a string for your PHP GD images.
[](https://patreon.com/agjopensource)
**imagecolorallocatefromstring** is an [agjgd](https://agjgd.org) project.
## Usage
### With Composer
This project offers support for the [Composer](https://getcomposer.org/) dependency manager. You can find the imagecolorallocatefromstring package online on [packagist.org](https://packagist.org/packages/andrewgjohnson/imagecolorallocatefromstring).
#### Install using Composer
Either run this command:
composer require andrewgjohnson/imagecolorallocatefromstring
or add this to the `require` section of your composer.json file:
"andrewgjohnson/imagecolorallocatefromstring": "1.*"
### Without Composer
To use without Composer add an [include](https://www.php.net/manual/en/function.include.php) to the [`imagecolorallocatefromstring.php` source file](https://raw.githubusercontent.com/andrewgjohnson/imagecolorallocatefromstring/master/source/imagecolorallocatefromstring.php).
include_once 'source/imagecolorallocatefromstring.php';
## Examples
// Allocate red with imagecolorallocate() or with imagecolorallocatefromstring() via a string
$red = imagecolorallocate($im, 0xFF, 0x00, 0x00);
$redFromString = imagecolorallocatefromstring($im, '#FF0000');
$redFromString = imagecolorallocatefromstring($im, '#f00');
$redFromString = imagecolorallocatefromstring($im, 'rgb(255 0 0)');
$redFromString = imagecolorallocatefromstring($im, 'rgb(255, 0, 0)');
$redFromString = imagecolorallocatefromstring($im, 'rgba(255, 0, 0, 1)');
$redFromString = imagecolorallocatefromstring($im, 'rgba(255 0 0 / 100%)');
$redFromString = imagecolorallocatefromstring($im, 'red');
There are [other examples](https://github.com/andrewgjohnson/imagecolorallocatefromstring/tree/master/examples) included in the GitHub repository and on [imagecolorallocatefromstring.agjgd.org](https://imagecolorallocatefromstring.agjgd.org/examples/).
## Help Requests
Please post any questions in the [discussions area](https://github.com/andrewgjohnson/imagecolorallocatefromstring/discussions) on GitHub if you need help.
If you discover a bug please [enter an issue](https://github.com/andrewgjohnson/imagecolorallocatefromstring/issues/new) on GitHub. When submitting an issue please use our [issue templates](https://github.com/andrewgjohnson/imagecolorallocatefromstring/tree/master/.github/ISSUE_TEMPLATE).
## Contributing
Please read our [contributing guidelines](https://github.com/andrewgjohnson/imagecolorallocatefromstring/blob/master/.github/CONTRIBUTING.md) if you want to contribute.
You can contribute financially by becoming a [patron](https://patreon.com/agjopensource) at [patreon.com/agjopensource](https://patreon.com/agjopensource) to support imagecolorallocatefromstring and [other agjgd.org projects](https://agjgd.org/projects/).
[](https://patreon.com/agjopensource)
## Acknowledgements
This project was started by [Andrew G. Johnson (@andrewgjohnson)](https://github.com/andrewgjohnson).
Full list of contributors:
* [Andrew G. Johnson (@andrewgjohnson)](https://github.com/andrewgjohnson)
Our [security policies and procedures](https://github.com/andrewgjohnson/imagecolorallocatefromstring/blob/master/.github/SECURITY.md) come via the [atomist/samples](https://github.com/atomist/samples/blob/master/SECURITY.md) project. Our [issue templates](https://github.com/andrewgjohnson/imagecolorallocatefromstring/tree/master/.github/ISSUE_TEMPLATE) come via the [tensorflow/tensorflow](https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md) project. Our [pull request template](https://github.com/andrewgjohnson/imagecolorallocatefromstring/blob/master/.github/PULL_REQUEST_TEMPLATE.md) comes via the [stevemao/github-issue-templates](https://github.com/stevemao/github-issue-templates) project. The [mountains photo](https://unsplash.com/photos/qJvpykJ5SKs) comes via [Gabriel Garcia Marengo](https://unsplash.com/@gabrielgm).
## Changelog
You can find all notable changes in the [changelog](https://github.com/andrewgjohnson/imagecolorallocatefromstring/blob/master/CHANGELOG.md).