material-palette-php icon indicating copy to clipboard operation
material-palette-php copied to clipboard

Bug. Warning: max(): Array must contain at least one element

Open Ne-Lexa opened this issue 7 years ago • 1 comments

An array of colors can be empty when there are no colors in the image. In the function max and min, you can not pass an empty array, otherwise the function will return false and throw warning.

Stacktrace:

Warning: max(): Array must contain at least one element

Exception trace:
 () at vendor/marijnvdwerf/material-palette/src/ColorCutQuantizer.php:101
 marijnvdwerf\palette\Vbox->getVolume() at vendor/marijnvdwerf/material-palette/src/ColorCutQuantizer.php:39
 marijnvdwerf\palette\ColorCutQuantizer->quantize() at vendor/marijnvdwerf/material-palette/src/PaletteGenerator.php:47
 marijnvdwerf\palette\PaletteGenerator->generate() at vendor/marijnvdwerf/material-palette/src/Palette.php:59

Sample code

$manager = new ImageManager();
$image = $manager->make('filename');
$palette = Palette::generate($image);
$palette->getVibrantSwatch()->getColor();

Problem image

icon

Ne-Lexa avatar Jun 29 '17 21:06 Ne-Lexa