PHP get image RGB Color value example, _php tutorial

Source: Internet
Author: User

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.