PhpImagick obtains the RGB color value of the image ,. PhpImagick gets the RGB color value of the image. many Image sites retrieve the main color value of the image based on the image uploaded by the user, and then search for the relevant image by color. Previously, follow php Imagick to obtain the RGB color 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/851334.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/851334.htmlTechArticlephp Imagick to obtain the image RGB color value, many Image sites will be based on the user to upload the image to retrieve the main color value of the image, and then in the color search related to the image. Previously...