PhpImagick obtains the RGB color of the image. PhpImagick obtains the RGB color value of an image. the main color value of the image is retrieved based on the user-uploaded image, and then the related image is searched based on the color, using the quantizeImage method of Imagick, you can use php Imagick to obtain the RGB color value of an image.
Retrieve the main color value of the image based on the uploaded image, and then search for the image based on the color. the quantizeImage method of Imagick can easily obtain the average RGB value of the image.
Many image sites retrieve the main color values of the image based on the image uploaded by the user, and then search for the relevant image by color.
Previously, the image was scaled (or mosaic) according to the online method, then each pixel was traversed, and the value of RGB was the most frequently. this was too inefficient and the obtained RGB value was not accurate enough. Then we can find that the average RGB value in the image can be easily obtained using the quantizeImage method of Imagick.
$ Average = new Imagick ("xiaocai.jpg ");
$ Average-> quantizeImage (10, Imagick: COLORSPACE_RGB, 0, false, false );
$ Average-> uniqueImageColors ();
Function GetImagesColor (Imagick $ im ){
$ Colorarr = array ();
$ It = $ im-> getPixelIterator ();
$ It-> resetIterator ();
While ($ row = $ it-> getNextIteratorRow ()){
Foreach ($ row as $ pixel ){
// Www.jbxue.com
$ Colorarr [] = $ pixel-> getColor ();
}
}
Return $ colorarr;
}
$ Colorarr = GetImagesColor ($ average );
Foreach ($ colorarr as $ val ){
Echo"
";
Http://www.bkjia.com/PHPjc/852826.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/852826.htmlTechArticlephp Imagick obtains the RGB color value of the image according to the user to upload the image to retrieve the main color value of the image, and then according to the color search related image, the use of the quantizeImage Imagick method can be very...