com php-src: - disable threshold for now, will enable it again using CIEDE2000: UPGRADING ext/gd/gd.c ext/gd/php_gd.h
| From: | Pierre Joye | Date: | Fri, 01 Mar 2013 07:10:49 +0000 |
| Subject: | com php-src: - disable threshold for now, will enable it again using CIEDE2000: UPGRADING ext/gd/gd.c ext/gd/php_gd.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-71393@lists.php.net to get a copy of this message | ||
Commit: 7698bc5735d188964cb98e6b6387c4cca26fcb0e
Author: Pierre Joye <pierre.php@gmail.com> Fri, 1 Mar 2013 08:10:49 +0100
Parents: 22aeb976e0a42c82cec594e8ca7b38846758c9b7
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7698bc5735d188964cb98e6b6387c4cca26fcb0e
Log:
- disable threshold for now, will enable it again using CIEDE2000
Changed paths:
M UPGRADING
M ext/gd/gd.c
M ext/gd/php_gd.h
Diff:
diff --git a/UPGRADING b/UPGRADING
index bc642aa..5f7d3ee 100755
--- a/UPGRADING
+++ b/UPGRADING
@@ -176,6 +176,7 @@ PHP 5.5 UPGRADE NOTES
- GD
- imageflip
+ - imagecrop
- Hash:
- hash_pbkdf2()
@@ -308,6 +309,19 @@ PHP 5.5 UPGRADE NOTES
- cURL:
- Added CURLOPT_SAFE_UPLOAD to be used with curl_setopt().
+- GD
+ - Added constants for imageflip:
+ . IMG_FLIP_HORIZONTAL
+ . IMG_FLIP_VERTICAL
+ . IMG_FLIP_BOTH
+ - Added constants for imagecrop
+ . IMG_CROP_DEFAULT
+ . IMG_CROP_TRANSPARENT
+ . IMG_CROP_BLACK
+ . IMG_CROP_WHITE
+ . IMG_CROP_SIDES
+ . IMG_CROP_THRESHOLD
+
========================================
10. Changes to INI File Handling
========================================
diff --git a/ext/gd/gd.c b/ext/gd/gd..c
index c004a72..7a2e214 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -891,6 +891,11 @@ ZEND_BEGIN_ARG_INFO(arginfo_imageflip, 0)
ZEND_ARG_INFO(0, mode)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO(arginfo_imagecrop, 0)
+ ZEND_ARG_INFO(0, im)
+ ZEND_ARG_INFO(0, rect)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO(arginfo_imagecropauto, 0)
ZEND_ARG_INFO(0, im)
ZEND_ARG_INFO(0, mode)
@@ -957,6 +962,7 @@ const zend_function_entry gd_functions[] = {
#ifdef HAVE_GD_BUNDLED
PHP_FE(imageantialias, arginfo_imageantialias)
PHP_FE(imageflip, arginfo_imageflip)
+ PHP_FE(imagecrop, arginfo_imagecrop)
PHP_FE(imagecropauto, arginfo_imagecropauto)
#endif
@@ -1218,7 +1224,10 @@ 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);
+#ifdef GD_ENABLE_CROP_THRESHOLD
REGISTER_LONG_CONSTANT("IMG_CROP_THRESHOLD", GD_CROP_THRESHOLD, CONST_CS |
CONST_PERSISTENT);
+#endif
+
#else
REGISTER_LONG_CONSTANT("GD_BUNDLED", 0, CONST_CS | CONST_PERSISTENT);
#endif
@@ -5141,9 +5150,69 @@ PHP_FUNCTION(imageflip)
}
/* }}} */
+/* {{{ proto void imagecrop(resource im, array rect)
+ Crop an image using the given coordinates and size, x, y, width and height. */
+PHP_FUNCTION(imagecrop)
+{
+ zval *IM;
+ long mode = -1;
+ long color = -1;
+ double threshold = 0.5f;
+ gdImagePtr im;
+ gdImagePtr im_crop;
+ HashTable rect_hash;
+ gdRect rect;
+ zval **tmp;
-/* {{{ proto void imageflip(resource im, int mode)
- Flip an image (in place) horizontally, vertically or both directions. */
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|h", &IM, &rect_hash) ==
FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
+
+ if (zend_hash_find(&rect_hash, "x", strlen("x"), (void **)&tmp) !=
FAILURE) {
+ rect.x = Z_LVAL_PP(tmp);
+ } else {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing x position");
+ RETURN_FALSE;
+ }
+
+ if (zend_hash_find(&rect_hash, "y", strlen("x"), (void **)&tmp) !=
FAILURE) {
+ rect.y = Z_LVAL_PP(tmp);
+ } else {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing y position");
+ RETURN_FALSE;
+ }
+
+ if (zend_hash_find(&rect_hash, "width", strlen("x"), (void **)&tmp) !=
FAILURE) {
+ rect.width = Z_LVAL_PP(tmp);
+ } else {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing width");
+ RETURN_FALSE;
+ }
+
+ if (zend_hash_find(&rect_hash, "height", strlen("x"), (void **)&tmp)
!= FAILURE) {
+ rect.width = Z_LVAL_PP(tmp);
+ } else {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Missing height");
+ RETURN_FALSE;
+ }
+
+ im_crop = gdImageCrop(im, &rect);
+
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown flip mode");
+ RETURN_FALSE;
+
+ if (im_crop == NULL) {
+ RETURN_FALSE;
+ } else {
+ ZEND_REGISTER_RESOURCE(return_value, im_crop, le_gd);
+ }
+}
+/* }}} */
+
+/* {{{ proto void imagecropauto(resource im [, int mode [, threshold [, color]]])
+ Crop an image automatically using one of the available modes. */
PHP_FUNCTION(imagecropauto)
{
zval *IM;
@@ -5169,7 +5238,7 @@ PHP_FUNCTION(imagecropauto)
case GD_CROP_SIDES:
im_crop = gdImageCropAuto(im, mode);
break;
-
+#ifdef GD_ENABLE_CROP_THRESHOLD
case GD_CROP_THRESHOLD:
if (color < 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Color argument missing with threshold
mode");
@@ -5177,7 +5246,7 @@ PHP_FUNCTION(imagecropauto)
}
im_crop = gdImageCropThreshold(im, color, (float) threshold);
break;
-
+#endif
default:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown flip mode");
RETURN_FALSE;
diff --git a/ext/gd/php_gd.h b/ext/gd/php_gd.h
index 537efc4..90ebd65 100644
--- a/ext/gd/php_gd.h
+++ b/ext/gd/php_gd.h
@@ -125,6 +125,7 @@ PHP_FUNCTION(imagerotate);
#ifdef HAVE_GD_BUNDLED
PHP_FUNCTION(imageantialias);
PHP_FUNCTION(imageflip);
+PHP_FUNCTION(imagecrop);
PHP_FUNCTION(imagecropauto);
#endif