PHP - 使用 ColorThief 提取图像颜色
PHP - Extract image colors with ColorThief
我在 GitHub 上找到了一个 class 来使用 php 提取图像颜色。首先我确实创建了一个 php 文件并将这些行添加到文件中:
require_once 'ColorThief.php';
$sourceImage = '1.jpg';
use ColorThief\ColorThief;
$palette = ColorThief::getPalette($sourceImage, 8);
但问题是我收到此错误消息,但我不知道如何解决它:
Fatal error: Class 'ColorThief\Image\ImageLoader' not found in C:\UwAmp\www\ColorThief\ColorThief.php on line 182
Call Stack
# Time Memory Function Location
1 0.0002 133416 {main}( ) ...\show.php:0
2 0.0038 198232 ColorThief\ColorThief::getPalette( ) ...\show.php:9
3 0.0038 198440 ColorThief\ColorThief::loadImage( ) ...\ColorThief.php:140
你们知道我如何使用这个class吗?
GitHub 页数:
使用 Composer 安装 Color Thief,这是在您的项目中使用第 3 方库的标准。
- 安装作曲家
- 例如通过 phpinfo 检查安装的这些库之一(gd 或 imagick)
gd (php_gd2.dll) - http://php.net/manual/en/image.installation.php
imagick (php_imagick.dll) - http://php.net/manual/en/imagick.setup.php
- 选择项目文件夹,然后运行
composer require ksubileau/color-thief-php
- 使用自动加载来包含 color-thief
require_once 'vendor/autoload.php';
我在 GitHub 上找到了一个 class 来使用 php 提取图像颜色。首先我确实创建了一个 php 文件并将这些行添加到文件中:
require_once 'ColorThief.php';
$sourceImage = '1.jpg';
use ColorThief\ColorThief;
$palette = ColorThief::getPalette($sourceImage, 8);
但问题是我收到此错误消息,但我不知道如何解决它:
Fatal error: Class 'ColorThief\Image\ImageLoader' not found in C:\UwAmp\www\ColorThief\ColorThief.php on line 182
Call Stack
# Time Memory Function Location
1 0.0002 133416 {main}( ) ...\show.php:0
2 0.0038 198232 ColorThief\ColorThief::getPalette( ) ...\show.php:9
3 0.0038 198440 ColorThief\ColorThief::loadImage( ) ...\ColorThief.php:140
你们知道我如何使用这个class吗? GitHub 页数:
使用 Composer 安装 Color Thief,这是在您的项目中使用第 3 方库的标准。
- 安装作曲家
- 例如通过 phpinfo 检查安装的这些库之一(gd 或 imagick)
gd (php_gd2.dll) - http://php.net/manual/en/image.installation.php
imagick (php_imagick.dll) - http://php.net/manual/en/imagick.setup.php
- 选择项目文件夹,然后运行
composer require ksubileau/color-thief-php
- 使用自动加载来包含 color-thief
require_once 'vendor/autoload.php';