Skip to content

Fix the imagecropauto() threshold color error message - #25385

Open
lacatoire wants to merge 1 commit into
php:masterfrom
lacatoire:fix/gd-imagecropauto-threshold-color-master
Open

lacatoire wants to merge 1 commit into
php:masterfrom
lacatoire:fix/gd-imagecropauto-threshold-color-master

Conversation

@lacatoire

@lacatoire lacatoire commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

imagecropauto() in threshold mode reports "must be greater than or equal to 0" for a non-negative colour that is not an index of the palette. Report the palette bound separately.

$p = imagecreate(6, 6);
imagecolorallocate($p, 255, 255, 255);
imagecolorallocate($p, 10, 10, 10);
imagecropauto($p, IMG_CROP_THRESHOLD, 0.5, imagecolorstotal($p));

Before: ValueError: imagecropauto(): Argument #4 ($color) must be greater than or equal to 0 when using the threshold mode

After: ValueError: imagecropauto(): Argument #4 ($color) must be a valid color index of the image when using the threshold mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant