svn: /pecl/gmagick/trunk/ gmagick.c gmagick_helpers.c gmagick_methods.c package.xml php_gmagick.h tests/gmagick-101-sharpenimage.phpt
tests/gmagick-102-unsharpenmaskimage.phpt
| From: | Vito Chin | Date: | Sun, 20 Oct 2013 09:48:06 +0000 |
| Subject: | svn: /pecl/gmagick/trunk/ gmagick.c gmagick_helpers.c gmagick_methods.c package.xml php_gmagick.h tests/gmagick-101-sharpenimage.phpt tests/gmagick-102-unsharpenmaskimage.phpt |
||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-19916@lists.php.net to get a copy of this message | ||
vito Sun, 20 Oct 2013 09:48:06 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=331867
Log:
Add unsharpenMaskImage and corresponding test
Changed paths:
U pecl/gmagick/trunk/gmagick.c
U pecl/gmagick/trunk/gmagick_helpers.c
U pecl/gmagick/trunk/gmagick_methods.c
U pecl/gmagick/trunk/package.xml
U pecl/gmagick/trunk/php_gmagick.h
U pecl/gmagick/trunk/tests/gmagick-101-sharpenimage.phpt
A pecl/gmagick/trunk/tests/gmagick-102-unsharpenmaskimage.phpt
Modified: pecl/gmagick/trunk/gmagick.c
===================================================================
--- pecl/gmagick/trunk/gmagick.c 2013-10-20 06:14:45 UTC (rev 331866)
+++ pecl/gmagick/trunk/gmagick.c 2013-10-20 09:48:06 UTC (rev 331867)
@@ -749,6 +749,14 @@
ZEND_ARG_INFO(0, stack)
ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(gmagick_unsharpmaskimage_args, 0, 0, 4)
+ ZEND_ARG_INFO(0, radius)
+ ZEND_ARG_INFO(0, sigma)
+ ZEND_ARG_INFO(0, amount)
+ ZEND_ARG_INFO(0, threshold)
+ZEND_END_ARG_INFO()
+
/* {{{ static zend_function_entry php_gmagick_functions[]
*/
static zend_function_entry php_gmagick_functions[] =
@@ -922,7 +930,7 @@
PHP_ME(gmagick, sampleimage, gmagick_sampleimage_args, ZEND_ACC_PUBLIC)
PHP_ME(gmagick, cloneimage, gmagick_empty_args, ZEND_ACC_PUBLIC)
PHP_ME(gmagick, appendimages, gmagick_appendimages_args, ZEND_ACC_PUBLIC)
-
+ PHP_ME(gmagick, unsharpmaskimage, gmagick_unsharpmaskimage_args, ZEND_ACC_PUBLIC)
PHP_MALIAS(gmagick, read, readimage, gmagick_readimage_args, ZEND_ACC_PUBLIC)
PHP_MALIAS(gmagick, write, writeimage, gmagick_writeimage_args, ZEND_ACC_PUBLIC)
{ NULL, NULL, NULL }
Modified: pecl/gmagick/trunk/gmagick_helpers.c
===================================================================
--- pecl/gmagick/trunk/gmagick_helpers.c 2013-10-20 06:14:45 UTC (rev 331866)
+++ pecl/gmagick/trunk/gmagick_helpers.c 2013-10-20 09:48:06 UTC (rev 331867)
@@ -602,3 +602,16 @@
}
return 1;
}
+
+/** zend_bool php_gmagick_thumbnail_dimensions(MagickWand *magick_wand, zend_bool bestfit, long
desired_width, long desired_height, long *new_width, long *new_height)
+*/
+
+zend_bool php_gmagick_ensure_not_empty (MagickWand *magick_wand)
+{
+ if (MagickGetNumberImages(magick_wand) == 0) {
+ TSRMLS_FETCH ();
+ GMAGICK_THROW_GMAGICK_EXCEPTION(magick_wand, "Can not process empty Gmagick object");
+ return 0;
+ }
+ return 1;
+}
Modified: pecl/gmagick/trunk/gmagick_methods.c
===================================================================
--- pecl/gmagick/trunk/gmagick_methods.c 2013-10-20 06:14:45 UTC (rev 331866)
+++ pecl/gmagick/trunk/gmagick_methods.c 2013-10-20 09:48:06 UTC (rev 331867)
@@ -4404,3 +4404,31 @@
return;
}
/* }}} */
+
+/* {{{ proto bool Gmagick::unsharpMaskImage(float radius, float sigma, float amount, float
threshold)
+ We convolve the image with a Gaussian operator of the given radius and standard deviation
(sigma). For reasonable results, radius should be larger than sigma. Use a radius of 0 and
Imagick::UnsharpMaskImage() selects a suitable radius for you.
+*/
+PHP_METHOD(gmagick, unsharpmaskimage)
+{
+ php_gmagick_object *intern;
+ double radius, sigma, amount, threshold;
+ MagickBool status;
+
+ /* Parse parameters given to function */
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd", &radius,
&sigma, &amount, &threshold) == FAILURE) {
+ return;
+ }
+
+ intern = (php_gmagick_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
+ if (php_gmagick_ensure_not_empty (intern->magick_wand) == 0)
+ return;
+
+ status = MagickUnsharpMaskImage(intern->magick_wand, radius, sigma, amount, threshold);
+
+ if (status == MagickFalse) {
+ GMAGICK_THROW_GMAGICK_EXCEPTION(intern->magick_wand, "Unable to unsharp mask
image");
+ return;
+ }
+ RETURN_TRUE;
+}
+/* }}} */
Modified: pecl/gmagick/trunk/package.xml
===================================================================
--- pecl/gmagick/trunk/package.xml 2013-10-20 06:14:45 UTC (rev 331866)
+++ pecl/gmagick/trunk/package.xml 2013-10-20 09:48:06 UTC (rev 331867)
@@ -19,10 +19,10 @@
<email>mkoppanen@php.net</email>
<active>yes</active>
</lead>
- <date>2012-12-27</date>
+ <date>2013-10-20</date>
<version>
- <release>1.1.2RC1</release>
- <api>1.1.2RC1</api>
+ <release>1.1.3RC1</release>
+ <api>1.1.3RC1</api>
</version>
<stability>
<release>beta</release>
@@ -30,20 +30,9 @@
</stability>
<license uri="http://www.php.net/license">PHP
License</license>
<notes>
-1. Version number updated.
-
-2. levelImage() will now choose between MagickLevelImage and MagickLevelImageChannel depending on
whether the channel is provided (the former if it isn't). To adjust the levels of an image by
scaling the colours falling between specified white and black points to the full available quantum
range, leave out the channel or use Gmagick::CHANNEL_DEFAULT. The range of applicable channels for
this method can be seen here:
-
-http://www.graphicsmagick.org/wand/magick_wand.html#magicklevelimagechannel
-
-Constants available here:
-
-http://www.php.net/manual/en/gmagick.constants.php
-Method interface is preserved.
-
-3. coalesceImage() method added.
-
-4. sharpenImage() method added.
+1. unsharpenMaskImage method and corresponding test added.
+2. Updated test for getQuantumDepth
+3. Version number updated
</notes>
<contents>
<dir name="/">
@@ -161,6 +150,9 @@
<file role="test" name="gmagick-097-sampleimage.phpt"/>
<file role="test" name="gmagick-098-cloneimage.phpt"/>
<file role="test" name="gmagick-099-appendimages.phpt"/>
+ <file role="test" name="gmagick-100-coalesceimages.phpt"/>
+ <file role="test" name="gmagick-101-sharpenimage.phpt"/>
+ <file role="test" name="gmagick-102-unsharpenmaskimage.phpt"/>
<file role="test"
name="gmagickdraw-001-setstrokecolor_setstrokewidth.phpt"/>
<file role="test" name="gmagickdraw-002-ellipse.phpt"/>
<file role="test" name="gmagickdraw-003-annotate.phpt"/>
Modified: pecl/gmagick/trunk/php_gmagick.h
===================================================================
--- pecl/gmagick/trunk/php_gmagick.h 2013-10-20 06:14:45 UTC (rev 331866)
+++ pecl/gmagick/trunk/php_gmagick.h 2013-10-20 09:48:06 UTC (rev 331867)
@@ -22,7 +22,7 @@
/* Define Extension Properties */
#define PHP_GMAGICK_EXTNAME "gmagick"
-#define PHP_GMAGICK_VERSION "1.1.2RC1"
+#define PHP_GMAGICK_VERSION "1.1.3RC1"
#define PHP_GMAGICK_EXTNUM 00001
#define MAX_BUFFER_SIZE 1024
@@ -286,6 +286,7 @@
PHP_METHOD(gmagick, sampleimage);
PHP_METHOD(gmagick, cloneimage);
PHP_METHOD(gmagick, appendimages);
+PHP_METHOD(gmagick, unsharpmaskimage);
/* draw */
PHP_METHOD(gmagickdraw, setstrokecolor);
PHP_METHOD(gmagickdraw, setstrokewidth);
Modified: pecl/gmagick/trunk/tests/gmagick-101-sharpenimage.phpt
===================================================================
--- pecl/gmagick/trunk/tests/gmagick-101-sharpenimage.phpt 2013-10-20 06:14:45 UTC (rev 331866)
+++ pecl/gmagick/trunk/tests/gmagick-101-sharpenimage.phpt 2013-10-20 09:48:06 UTC (rev 331867)
@@ -1,5 +1,5 @@
--TEST--
-sharpenmage test
+sharpenimage test
--SKIPIF--
<?php
if(!extension_loaded('gmagick')) die('skip');
Added: pecl/gmagick/trunk/tests/gmagick-102-unsharpenmaskimage.phpt
===================================================================
--- pecl/gmagick/trunk/tests/gmagick-102-unsharpenmaskimage.phpt (rev 0)
+++ pecl/gmagick/trunk/tests/gmagick-102-unsharpenmaskimage.phpt 2013-10-20 09:48:06 UTC (rev
331867)
@@ -0,0 +1,14 @@
+--TEST--
+unsharpmaskimage test
+--SKIPIF--
+<?php
+if(!extension_loaded('gmagick')) die('skip');
+?>
+--FILE--
+<?php
+$image = new Gmagick('magick:rose');
+$image->unsharpMaskImage(0 , 0.5 , 1 , 0.05);
+echo "ok";
+?>
+--EXPECTF--
+ok