PHP code example of richarddobron / php-avg-color-picker

1. Go to this page and download the library: Download richarddobron/php-avg-color-picker 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/ */

    

richarddobron / php-avg-color-picker example snippets




use Dobron\AvgColorPicker\Gd\AvgColorPicker;

$imageAvgRgbColor = (new AvgColorPicker)->getImageAvgRgb('image.png');
// or
$imageAvgRgbColor = (new AvgColorPicker)->getImageAvgRgb(imagecreatefrompng('image.png'));

var_dump($imageAvgRgbColor); // array(255, 255, 255)



use Dobron\AvgColorPicker\Gd\AvgColorPicker;

$imageAvgHexColor = (new AvgColorPicker)->getImageAvgHex('image.gif');
// or
$imageAvgHexColor = (new AvgColorPicker)->getImageAvgHex(imagecreatefromgif('image.gif'));

var_dump($imageAvgHexColor); // string(7) "#ffffff"
shell
$ composer