com php-src: - clean and enable threshold: ext/gd/gd.c ext/gd/libgd/gd.h ext/gd/libgd/gd_crop.c
| From: | Pierre Joye | Date: | Thu, 28 Feb 2013 18:22:06 +0000 |
| Subject: | com php-src: - clean and enable threshold: ext/gd/gd.c ext/gd/libgd/gd.h ext/gd/libgd/gd_crop.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-71395@lists.php.net to get a copy of this message | ||
Commit: 0c32a18d4c9995fe101484eef46e292a51543b68
Author: Pierre Joye <pierre.php@gmail.com> Thu, 28 Feb 2013 19:22:06 +0100
Parents: a991360344ed5bca7c20f74a10891d0fc52f0c9f
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0c32a18d4c9995fe101484eef46e292a51543b68
Log:
- clean and enable threshold
Changed paths:
M ext/gd/gd.c
M ext/gd/libgd/gd.h
M ext/gd/libgd/gd_crop.c
Diff:
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index 83733d1..c004a72 100644
--- a/ext/gd/gd.c
+++ b/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;
diff --git a/ext/gd/libgd/gd.h b/ext/gd/libgd/gd.h
index adef026..8d9df2a 100644
--- a/ext/gd/libgd/gd.h
+++ b/ext/gd/libgd/gd.h
@@ -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);
diff --git a/ext/gd/libgd/gd_crop.c b/ext/gd/libgd/gd_crop.c
index d5fd762..274e719 100644
--- a/ext/gd/libgd/gd_crop.c
+++ b/ext/gd/libgd/gd_crop.c
@@ -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) {