mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Resolve imagecropauto() default $mode quirk
The `$mode` parameter of `imagecropauto()` defaults to `-1`. However, `-1` is changed to `GD_CROP_DEFAULT` right away, so basically the default is `GD_CROP_DEFAULT`, which is rather confusing and unnecessary. Therefore, we change the default to `IMG_CROP_DEFAULT`, but still allow an explicit `-1` to be passed for BC reasons, in which case we trigger a deprecation notice, so we can rid the `-1` support eventually.
This commit is contained in:
parent
40c4d7f182
commit
8c781c1c20
2
NEWS
2
NEWS
@ -19,6 +19,8 @@ PHP NEWS
|
||||
pkg-config). (Eli Schwartz)
|
||||
. The bundled libgd behaves now like system libgd wrt. IMG_CROP_DEFAULT never
|
||||
falling back to IMG_CROP_SIDES.
|
||||
. The default $mode parameter of imagecropauto() has been changed to
|
||||
IMG_CROP_DEFAULT; passing -1 is now deprecated.
|
||||
|
||||
- Hash:
|
||||
. The hash extension is now an integral part of PHP and cannot be disabled
|
||||
|
@ -120,6 +120,8 @@ PHP 7.4 UPGRADE NOTES
|
||||
that of system libgd:
|
||||
* IMG_CROP_DEFAULT is no longer falling back to IMG_CROP_SIDES
|
||||
* Threshold-cropping now uses the algorithm of system libgd
|
||||
. The default $mode parameter of imagecropauto() has been changed to
|
||||
IMG_CROP_DEFAULT; passing -1 is now deprecated.
|
||||
|
||||
- Hash:
|
||||
. The hash extension cannot be disabled anymore and is always an integral
|
||||
|
@ -4685,12 +4685,12 @@ PHP_FUNCTION(imagecrop)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto resource imagecropauto(resource im [, int mode [, float threshold [, int color]]])
|
||||
/* {{{ proto resource imagecropauto(resource im [, int mode = GD_CROP_DEFAULT [, float threshold [, int color]]])
|
||||
Crop an image automatically using one of the available modes. */
|
||||
PHP_FUNCTION(imagecropauto)
|
||||
{
|
||||
zval *IM;
|
||||
zend_long mode = -1;
|
||||
zend_long mode = GD_CROP_DEFAULT;
|
||||
zend_long color = -1;
|
||||
double threshold = 0.5f;
|
||||
gdImagePtr im;
|
||||
@ -4706,7 +4706,9 @@ PHP_FUNCTION(imagecropauto)
|
||||
|
||||
switch (mode) {
|
||||
case -1:
|
||||
php_error_docref(NULL, E_DEPRECATED, "Crop mode -1 is deprecated. Use IMG_CROP_DEFAULT instead.");
|
||||
mode = GD_CROP_DEFAULT;
|
||||
/* FALLTHRU */
|
||||
case GD_CROP_DEFAULT:
|
||||
case GD_CROP_TRANSPARENT:
|
||||
case GD_CROP_BLACK:
|
||||
|
Loading…
Reference in New Issue
Block a user