material-palette-php
material-palette-php copied to clipboard
Bug. Warning: max(): Array must contain at least one element
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();