PHP code example of dneustadt / average-color-matrix

1. Go to this page and download the library: Download dneustadt/average-color-matrix library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dneustadt / average-color-matrix example snippets


$matrix = new \AverageColorMatrix\AverageColorMatrix(
    __DIR__ .  DIRECTORY_SEPARATOR . $filename
);
  
$matrix->get(4, 4);

array(3) {
  ["y_percent"]=>
  float(25)
  ["x_percent"]=>
  float(25)
  ["tiles"]=>
  array(4) {
    [0]=>
    array(4) {
      [0]=>
      array(4) {
        ["r"]=>
        int(214)
        ["g"]=>
        int(215)
        ["b"]=>
        int(220)
        ["hex"]=>
        string(7) "#d6d7dc"
      }
      [...]
    }
    [...]
  }
}