hracik/php-recognize-average-color-from-image
Composer 安装命令:
composer require hracik/php-recognize-average-color-from-image
包简介
Recognize average color from image.
README 文档
README
Recognize average color from image - can be external image URL or local file.
Getting Started
These instructions will get you a copy of the project up and running
Installing
Install with Composer
composer require hracik/php-recognize-average-color-from-image
Usage
If you want to alter average color, e.g. to use the color on web dark/light designs, you can provide custom saturation and lightness within options.
use Hracik\RecognizeAverageColorFromImage; //can be path to local image or URL $path = 'https://raw.githubusercontent.com/hracik/php-recognize-average-color-from-image/master/example/example2.jpg; //possible return options are: RETURN_STRING_HEX, RETURN_STRING_RGB, RETURN_ARRAY_RGB, RETURN_ARRAY_RGB_NORMALIZED, RETURN_ARRAY_HSL $return = RecognizeAverageColorFromImage::RETURN_STRING_HEX; //only accepted keys are saturation and lightness $options = ['saturation' => 0.6, 'lightness' => 0.3]; $color = RecognizeAverageColorFromImage::getAverageColor($path, $return); echo $color;
Output #707A1E. Same image without options return color #838B45.
Or just get counted average without options attribute.
use Hracik\RecognizeAverageColorFromImage; $path = 'https://raw.githubusercontent.com/hracik/php-recognize-average-color-from-image/master/example/example3.jpg; $color = RecognizeAverageColorFromImage::getAverageColor($path, RecognizeAverageColorFromImage::RETURN_STRING_HEX); echo $color;
Output #658FAD.
Running the tests
Run
./vendor/bin/phpunit --bootstrap vendor/autoload.php tests
For Windows platforms
./vendor/bin/phpunit.bat --bootstrap vendor/autoload.php tests
Built With
- PHPUnit - The PHP Testing Framework
- PHP: ImageMagick - Manual
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- Andrej Lahucky - Initial work - Hracik
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
Acknowledgments
- PurpleBooth
统计信息
- 总下载量: 150
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-06-15