thephpleague / color-extractor

Extract colors from an image like a human would do.
thephpleague.com
MIT License
1.3k stars 159 forks source link

Update readme to mention GD support requirement #23

Closed glasnt closed 9 years ago

glasnt commented 9 years ago

I had issues trying to use this library initially, because I didn't realize it was using GD manipulations under the hood, and by default my (and possibly most) php installations don't include GD support out of the box.

I found the documentation and comments at http://php.net/manual/en/image.installation.php helpful in order to install php5-gd on my debian-based distro in order to use this library.

Without GD support, errors occur such as:

Call to undefined function League\ColorExtractor\imagecreatefrompng() in [...]/vendor/league/color-extractor/src/League/ColorExtractor/Client.php on line 14

In order to help others, I submit this README.md update comment referencing the php.net documentation.

MatTheCat commented 9 years ago

You can see here GD is a requirement. Were you able to install it without any error from composer?

glasnt commented 9 years ago

Ah, so it should have installed something. I followed the exact command in the README file, received no error from composer; but on testing the code snippet received the aforementioned error. Full logs below.

$ composer require league/color-extractor:0.1.*
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing league/color-extractor (0.1.0)
    Loading from cache

Writing lock file
Generating autoload files

$ php -S localhost:4000
PHP 5.5.12-2ubuntu4.1 Development Server started at Fri Nov 21 21:07:00 2014
Listening on http://localhost:4000
Document root is [...]
Press Ctrl-C to quit.
[Fri Nov 21 21:07:04 2014] 127.0.0.1:53522 [200]: /
[Fri Nov 21 21:07:04 2014] 127.0.0.1:53523 [404]: /favicon.ico - No such file or directory
[Fri Nov 21 21:08:18 2014] PHP Fatal error:  Call to undefined function League\ColorExtractor\imagecreatefromjpeg() in [..]/vendor/league/color-extractor/src/League/ColorExtractor/Client.php on line 9
[Fri Nov 21 21:08:18 2014] 127.0.0.1:53526 [500]: /color_extract.php - Call to undefined function League\ColorExtractor\imagecreatefromjpeg() in [...]/vendor/league/color-extractor/src/League/ColorExtractor/Client.php on line 9
[Fri Nov 21 21:08:26 2014] 127.0.0.1:53527 Invalid request (Unexpected EOF)

My apologies if this is just user error on my part.

MatTheCat commented 9 years ago

Thanks for the logs. It's strange you didn't have any error. You can see here ext-gd was supposed to prevent you from installing color-extractor without the extension.

Are you sure gd wasn't activated only on your CLI?

glasnt commented 9 years ago

I've taken some time in order to work out where in the workflow this issue was being created, but I can't reproduce it any more.

I walked through the travisci before_script steps, and only then was I able to get my first Your requirements could not be resolved to an installable set of packages. warning.

This isn't an issue with color-extractor, but somewhere at the composer level, or user error. I will close this issue.