![]() ![]() If you need 4 colors in the pallet, scale it down to about 8x8, 6 colors to about 12x8 and so on. You need to scale down the picture and you will get the main colors of the picture. So I am asking if anyone knows how I can do such a task with PHP? Possibly something exist already that you know of or any tips to put me a step closer to doing this would be appreciated Imagecopyresampled($image_resized, $image_orig, 0, 0, 0, 0, $width, $height, $size, $size) //WE NEED NEAREST NEIGHBOR RESIZING, BECAUSE IT DOESN'T ALTER THE COLORS $image_orig=imagecreatefrompng($this->image) $image_orig=imagecreatefromjpeg($this->image) $scale = min($PREVIEW_WIDTH/$size, $PREVIEW_HEIGHT/$size) $PREVIEW_WIDTH = 150 //WE HAVE TO RESIZE THE IMAGE, BECAUSE WE ONLY NEED THE MOST SIGNIFICANT COLORS. ![]() * Returns the colors of the image in an array, ordered in descending order, where the keys are the colors, and the values are the count of the color. I had found this function that will return the colors and count in an Image with PHP but the results are different from the Javascript version above and the Dribble results /** So I am hoping to be able to do what that Javascript library does but with PHP and GD/ImageMagick Viewing the source of that page I can see there is a Javascript file named quantize.js and the results are really good. In the image below the Dribble shot below is a Javascript library that does the same thing, that page can be viewed here They say you need to Quantize the image/colors (I am lost at this point). ![]() Other say there is more to it and that getting the colors that exist the most frequent won't give the desired affect. I need to be able to do this in PHP, once I get the colors I need I will save them to a database so the processing does not need to be run on every page load.Īfter some research on how to get these colors out of an Image, some people said you simply examine an image pixel by pixel and then save the colors that occur the most. There are 5 other projects in the npm registry using extract-colors. Start using extract-colors in your project by running npm i extract-colors. In the image below you can see a screenshot from that shows the 8 predominant colors in the image to the left. Latest version: 3.0.0, last published: 4 months ago. The Palette library attempts to extract the following six color profiles: Light. I am trying to replicate the functionality that does with detecting the predominant colors in an Image. By default, a Palette object contains 16 primary colors from a given image. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |