PHP Gets an example of an image RGB color value,
PHP get image RGB Color Value example
Many image sites will retrieve the primary color value of the image based on the images uploaded by the user, and then search for related images by color.
Before using the online method to zoom (or mosaic) the image and then traverse each pixel, and then statistics the most RGB number of values, this practice is too low and the RGB value is not accurate. It was later found that the Quantizeimage method using Imagick can easily fetch the average RGB value in the image.
$average=NewImagick ("Xiaocai.jpg");$average->quantizeimage (Imagick::colorspace_rgb, 0,false,false );$average-uniqueimagecolors ();functionGetimagescolor (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"$val[' R ']},{$val[' G ']},{$val[' B ']}); Width:50px;height:50px;float:left; ' > ";}
Articles you may be interested in:
- PHP scans the image pixel to get the color value per pixel and output
- What are the methods for getting image color values in PHP?
- PHP Get Image Color Value example
- PHP Color Value conversion PHP Implementation 16 binary number and color value conversion
http://www.bkjia.com/PHPjc/848236.html www.bkjia.com true http://www.bkjia.com/PHPjc/848236.html techarticle PHP Gets the image RGB color value example, PHP obtains the image RGB color value example many picture sites will retrieve the picture's main color value according to the user to upload the picture, then in through Yan ...