thephpleague / color-extractor

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

speed #12

Closed notflip closed 2 years ago

notflip commented 10 years ago

Is it me or is the calculation happening very slow? Nice script by the way!

MatTheCat commented 10 years ago

Well as it looks into every pixel I advise you not to use it with large images.

philsturgeon commented 10 years ago

Could you put some sort of advisory warning on the docs to explain this? Maybe suggest it goes in a background job?

Is it certain file types, or will all files be slow?

a-x- commented 9 years ago

:+1:

GrahamCampbell commented 9 years ago

Would we get it to take a sample on large images?

MatTheCat commented 9 years ago

Commit bf972826acc95cbb948f166110559c21bb3720d3 should improve speed.

chonz0 commented 9 years ago

First, I would like to thank you very much for this nice piece of code :) it's awesome Second, I've found that most images are procesed in about 1-3 seconds tops. BUT there are a few that takes more than 90 seconds -which is my PHP max_execution_time setting-, so it ends up on a fatal error. I don't really know what's the cause of this, so here's one of the images that causes such issue, in case you are interested in taking a look a it: https://unsplash.imgix.net/uploads/1412862685615b0212e3d/5fcb0a55?q=75&fm=jpg&s=e003fb9a4e39e3c07e4a94f7e0ef3db8

Cheers!

MatTheCat commented 9 years ago

Thanks ^^

I've got no error trying to process the image, it took 3-5s even so it's pretty large. Are you sure you're using the latest version (0.1.7 now)? How many colors did you want to extract?

chonz0 commented 9 years ago

Thanks a lot for your reply :-) You were right, I've updated by running "composer update league/color-extractor:0.1.*" but got a "Nothing to install or update". After reading your response, I've run:

composer update leage/color-extractor:0.1.7

and that did it!

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing league/color-extractor (0.1.6)
  - Installing league/color-extractor (0.1.7)
    Downloading: connection...    Downloading: 100%

Thanks again for this great library! Keep up the good work! ;-)

MatTheCat commented 9 years ago

You're welcome! I think what you saw is related to #11

pySilver commented 8 years ago

Hint: I bet performance might be improved if one create a thumbnail first.