richarddobron/php-avg-color-picker
Composer 安装命令:
composer require richarddobron/php-avg-color-picker
包简介
The PHP Average Color Picker Library
README 文档
README
A simple, lightweight and fast PHP function that uses the GD library to extract the average color of an image.
Note
Keep in mind that this function will return the average color of an image, not the main color.
📖 Requirements
- PHP 7.0 or higher
- Composer is required for installation
- PHP Extensions:
ext-mbstring,ext-gd,ext-fileinfo,ext-ctype
📦 Installation
Install the library using Composer:
$ composer require richarddobron/php-avg-color-picker
👀 Example
Input - The Image Path
Output - The Image Average Color
⚡️ Quick Start
Here’s how to use the library to determine the average color of an image:
<?php use Dobron\AvgColorPicker\Gd\AvgColorPicker; $imageAvgRgbColor = (new AvgColorPicker)->getImageAvgRgb('image.png'); // or $imageAvgRgbColor = (new AvgColorPicker)->getImageAvgRgb(imagecreatefrompng('image.png')); var_dump($imageAvgRgbColor); // array(255, 255, 255)
<?php use Dobron\AvgColorPicker\Gd\AvgColorPicker; $imageAvgHexColor = (new AvgColorPicker)->getImageAvgHex('image.gif'); // or $imageAvgHexColor = (new AvgColorPicker)->getImageAvgHex(imagecreatefromgif('image.gif')); var_dump($imageAvgHexColor); // string(7) "#ffffff"
🧪 Testing
$ composer tests
🤝 Contributing
Please see CONTRIBUTING for details.
⚖️ License
This repository is MIT licensed, as found in the LICENSE file.
统计信息
- 总下载量: 6.13k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-10

