tooleks/php-avg-color-picker 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tooleks/php-avg-color-picker

最新稳定版本:1.1.2

Composer 安装命令:

composer require tooleks/php-avg-color-picker

包简介

The PHP Average Color Picker Library

README 文档

README

The package provides the library for picking an average color from the given image. Currently it supports image/png, image/jpeg, image/gif image MIME types.

Example

Input - The Image Path

The Image Path
Input

Output - The Image Average Color

The Image Average Color
Output

Requirements

"php": "^7.0", "ext-mbstring": "*", "ext-gd": "*"

Installation

Package Installation

Execute the following command to get the latest version of the package:

composer require tooleks/php-avg-color-picker

Usage Examples

<?php

use Tooleks\Php\AvgColorPicker\Gd\AvgColorPicker;

$imageAvgRgbColor = (new AvgColorPicker)->getImageAvgRgbByPath($imagePath);
// or
$imageAvgRgbColor = (new AvgColorPicker)->getImageAvgRgbByResource($gdImageResource);
// or
$imageAvgRgbColor = (new AvgColorPicker)->getImageAvgRgb($imagePath);
// or
$imageAvgRgbColor = (new AvgColorPicker)->getImageAvgRgb($gdImageResource);

// The `$imageAvgRgbColor` variable contains the average color of the given image in RGB format (array)[255, 255, 255].
<?php

use Tooleks\Php\AvgColorPicker\Gd\AvgColorPicker;

$imageAvgHexColor = (new AvgColorPicker)->getImageAvgHexByPath($imagePath);
// or
$imageAvgHexColor = (new AvgColorPicker)->getImageAvgHexByResource($gdImageResource);
// or
$imageAvgHexColor = (new AvgColorPicker)->getImageAvgHex($imagePath);
// or
$imageAvgHexColor = (new AvgColorPicker)->getImageAvgHex($gdImageResource);

// The `$imageAvgHexColor` variable contains the average color of the given image in HEX format (string)"#fffff".

You can use the calculated value to show the average image color in its container before the image is loaded.

<div style="background-color: <?= $imageAvgHexColor ?>; width: <?= $imageWidth ?>; height: <?= $imageHeight ?>;">
    <img src="/url/to/the/image.(jpg|jpeg|png|gif)" alt="">
</div>

Tests

Execute the following command to run tests:

./vendor/bin/phpunit

统计信息

  • 总下载量: 105.49k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固