mirror of
https://github.com/php/php-src.git
synced 2026-04-21 06:51:18 +02:00
- clean and enable threshold
This commit is contained in:
16
ext/gd/gd.c
16
ext/gd/gd.c
@@ -894,6 +894,8 @@ ZEND_END_ARG_INFO()
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_imagecropauto, 0)
|
||||
ZEND_ARG_INFO(0, im)
|
||||
ZEND_ARG_INFO(0, mode)
|
||||
ZEND_ARG_INFO(0, threshold)
|
||||
ZEND_ARG_INFO(0, color)
|
||||
ZEND_END_ARG_INFO()
|
||||
#endif
|
||||
|
||||
@@ -1216,6 +1218,7 @@ PHP_MINIT_FUNCTION(gd)
|
||||
REGISTER_LONG_CONSTANT("IMG_CROP_BLACK", GD_CROP_BLACK, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("IMG_CROP_WHITE", GD_CROP_WHITE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("IMG_CROP_SIDES", GD_CROP_SIDES, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("IMG_CROP_THRESHOLD", GD_CROP_THRESHOLD, CONST_CS | CONST_PERSISTENT);
|
||||
#else
|
||||
REGISTER_LONG_CONSTANT("GD_BUNDLED", 0, CONST_CS | CONST_PERSISTENT);
|
||||
#endif
|
||||
@@ -5145,10 +5148,12 @@ PHP_FUNCTION(imagecropauto)
|
||||
{
|
||||
zval *IM;
|
||||
long mode = -1;
|
||||
long color = -1;
|
||||
double threshold = 0.5f;
|
||||
gdImagePtr im;
|
||||
gdImagePtr im_crop;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &IM, &mode) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|ldl", &IM, &mode, &threshold, &color) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5164,6 +5169,15 @@ PHP_FUNCTION(imagecropauto)
|
||||
case GD_CROP_SIDES:
|
||||
im_crop = gdImageCropAuto(im, mode);
|
||||
break;
|
||||
|
||||
case GD_CROP_THRESHOLD:
|
||||
if (color < 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Color argument missing with threshold mode");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
im_crop = gdImageCropThreshold(im, color, (float) threshold);
|
||||
break;
|
||||
|
||||
default:
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown flip mode");
|
||||
RETURN_FALSE;
|
||||
|
||||
@@ -733,7 +733,8 @@ enum gdCropMode {
|
||||
GD_CROP_TRANSPARENT,
|
||||
GD_CROP_BLACK,
|
||||
GD_CROP_WHITE,
|
||||
GD_CROP_SIDES
|
||||
GD_CROP_SIDES,
|
||||
GD_CROP_THRESHOLD
|
||||
};
|
||||
|
||||
gdImagePtr gdImageCrop(gdImagePtr src, const gdRectPtr crop);
|
||||
|
||||
@@ -58,7 +58,7 @@ gdImagePtr gdImageCrop(gdImagePtr src, const gdRectPtr crop)
|
||||
if (src->sy < (crop->y + crop->height -1)) {
|
||||
crop->height = src->sy - crop->y + 1;
|
||||
}
|
||||
#ifdef 0
|
||||
#if 0
|
||||
printf("rect->x: %i\nrect->y: %i\nrect->width: %i\nrect->height: %i\n", crop->x, crop->y, crop->width, crop->height);
|
||||
#endif
|
||||
if (dst == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user