Skip to content

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

@Ne-Lexa

Description

@Ne-Lexa

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions