【问题标题】:PHP - Extract image colors with ColorThiefPHP - 使用 ColorThief 提取图像颜色
【发布时间】:2018-09-29 04:28:17
【问题描述】:

我在 GitHub 上找到了一个用 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

你们知道我如何使用这个类吗? GitHub页面:

https://github.com/ksubileau/color-thief-php

【问题讨论】:

  • 您是否使用 composer 安装了 ColorThief 而没有出现我们的错误?
  • 没有作曲家

标签: php colors extract


【解决方案1】:

使用 Composer 安装 Color Thief,这是在您的项目中使用 3rd 方库的标准。

  1. 安装 Composer
  2. 例如通过 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

  1. 选择项目文件夹并运行

作曲家需要 ksubileau/color-thief-php

  1. 使用自动加载来包含颜色小偷

require_once 'vendor/autoload.php';

【讨论】:

    猜你喜欢
    • 2019-04-30
    • 2019-02-16
    • 1970-01-01
    • 2011-12-05
    • 2012-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-04
    相关资源
    最近更新 更多