cvs: pear /PECL/imagick imagick.c package.xml php_imagick.h /PECL/imagick/examples setcompression.php
| From: | Michael C. Montero | Date: | Tue, 18 Feb 2003 17:41:54 +0000 |
| Subject: | cvs: pear /PECL/imagick imagick.c package.xml php_imagick.h /PECL/imagick/examples setcompression.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-8947@lists.php.net to get a copy of this message | ||
mcmontero Tue Feb 18 12:41:54 2003 EDT
Added files:
/pear/PECL/imagick/examples setcompression.php
Modified files:
/pear/PECL/imagick imagick.c package.xml php_imagick.h
Log:
- added imagick_setcompression() and related IMAGICK_COMPRESSION_*
constants.
- thanks to James Huston (hustonjs@itadevelopment.com) for suggesting
imagick_setcompression() and testing it.
Index: pear/PECL/imagick/imagick.c
diff -u pear/PECL/imagick/imagick.c:1.34 pear/PECL/imagick/imagick.c:1.35
--- pear/PECL/imagick/imagick.c:1.34 Tue Feb 18 12:16:44 2003
+++ pear/PECL/imagick/imagick.c Tue Feb 18 12:41:53 2003
@@ -16,7 +16,7 @@
| Christian Stocker (chregu@bitflux.ch) |
+----------------------------------------------------------------------+
- $Id: imagick.c,v 1.34 2003/02/18 17:16:44 mcmontero Exp $
+ $Id: imagick.c,v 1.35 2003/02/18 17:41:53 mcmontero Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -89,6 +89,7 @@
*****/
PHP_FE( imagick_convert, NULL )
+ PHP_FE( imagick_setcompression, NULL )
/*****
@@ -588,6 +589,43 @@
sRGBColorspace,
CONST_CS | CONST_PERSISTENT ) ;
+ /*****
+
+ Register constants for compression types.
+
+ *****/
+
+ REGISTER_LONG_CONSTANT( "IMAGICK_COMPRESSION_UNDEFINED",
+ UndefinedCompression,
+ CONST_CS | CONST_PERSISTENT ) ;
+ REGISTER_LONG_CONSTANT( "IMAGICK_COMPRESSION_NONE",
+ NoCompression,
+ CONST_CS | CONST_PERSISTENT ) ;
+ REGISTER_LONG_CONSTANT( "IMAGICK_COMPRESSION_BZIP",
+ BZipCompression,
+ CONST_CS | CONST_PERSISTENT ) ;
+ REGISTER_LONG_CONSTANT( "IMAGICK_COMPRESSION_FAX",
+ FaxCompression,
+ CONST_CS | CONST_PERSISTENT ) ;
+ REGISTER_LONG_CONSTANT( "IMAGICK_COMPRESSION_GROUP4",
+ Group4Compression,
+ CONST_CS | CONST_PERSISTENT ) ;
+ REGISTER_LONG_CONSTANT( "IMAGICK_COMPRESSION_JPEG",
+ JPEGCompression,
+ CONST_CS | CONST_PERSISTENT ) ;
+ REGISTER_LONG_CONSTANT( "IMAGICK_COMPRESSION_LOSSLESSJPEG",
+ LosslessJPEGCompression,
+ CONST_CS | CONST_PERSISTENT ) ;
+ REGISTER_LONG_CONSTANT( "IMAGICK_COMPRESSION_LZW",
+ LZWCompression,
+ CONST_CS | CONST_PERSISTENT ) ;
+ REGISTER_LONG_CONSTANT( "IMAGICK_COMPRESSION_RLE",
+ RLECompression,
+ CONST_CS | CONST_PERSISTENT ) ;
+ REGISTER_LONG_CONSTANT( "IMAGICK_COMPRESSION_ZIP",
+ ZipCompression,
+ CONST_CS | CONST_PERSISTENT ) ;
+
return SUCCESS ;
}
@@ -1637,6 +1675,39 @@
*****/
+ RETURN_TRUE ;
+}
+
+PHP_FUNCTION( imagick_setcompression )
+{
+ zval* handle_id ; /* the handle identifier coming from
+ the PHP environment */
+ long compression_type ; /* the compression type to set */
+ imagick_t* handle ; /* the actual imagick_t struct for the
+ handle */
+
+ if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rl",
+ &handle_id, &compression_type ) == FAILURE )
+ {
+ return ;
+ }
+
+ handle = _php_imagick_get_handle_struct_from_list( &handle_id TSRMLS_CC ) ;
+ if ( !handle )
+ {
+ php_error( E_WARNING, "%s(): handle is invalid",
+ get_active_function_name( TSRMLS_C ) ) ;
+ RETURN_FALSE ;
+ }
+
+ _php_imagick_clear_errors( handle ) ;
+
+ if ( handle->image == ( Image* )NULL )
+ {
+ RETURN_FALSE ;
+ }
+
+ handle->image->compression = ( CompressionType )compression_type ;
RETURN_TRUE ;
}
Index: pear/PECL/imagick/package.xml
diff -u pear/PECL/imagick/package.xml:1.42 pear/PECL/imagick/package.xml:1.43
--- pear/PECL/imagick/package.xml:1.42 Tue Feb 18 12:16:44 2003
+++ pear/PECL/imagick/package.xml Tue Feb 18 12:41:53 2003
@@ -31,11 +31,14 @@
imagick_pushlist()
imagick_poplist()
imagick_mosaic()
+ imagick_setcompression()
- modified how all functions check to see if ImageMagick has been initialized.
- added a number of new examples for demonstrating how to use image lists.
- fixed bugs in _php_imagick_alloc_handle() and _php_imagick_clear_errors()
causing core dump when working with image lists. I wasn't checking to make
sure the structures I was examining were allocated.
+- thanks to James Huston (hustonjs@itadevelopment.com) for suggesting
+ imagick_setcompression() and testing it.
</notes>
<state>beta</state>
</release>
Index: pear/PECL/imagick/php_imagick.h
diff -u pear/PECL/imagick/php_imagick.h:1.22 pear/PECL/imagick/php_imagick.h:1.23
--- pear/PECL/imagick/php_imagick.h:1.22 Tue Feb 18 12:16:45 2003
+++ pear/PECL/imagick/php_imagick.h Tue Feb 18 12:41:53 2003
@@ -16,7 +16,7 @@
| Christian Stocker (chregu@bitflux.ch) |
+----------------------------------------------------------------------+
- $Id: php_imagick.h,v 1.22 2003/02/18 17:16:45 mcmontero Exp $
+ $Id: php_imagick.h,v 1.23 2003/02/18 17:41:53 mcmontero Exp $
*/
#ifndef PHP_IMAGICK_H
@@ -101,6 +101,7 @@
*****/
PHP_FUNCTION( imagick_convert ) ;
+ PHP_FUNCTION( imagick_setcompression ) ;
/*****
Index: pear/PECL/imagick/examples/setcompression.php
+++ pear/PECL/imagick/examples/setcompression.php
<?
$handle = imagick_readimage( "./image.jpg" ) ;
if ( imagick_iserror( $handle ) )
{
$reason = imagick_failedreason( $handle ) ;
$description = imagick_faileddescription( $handle ) ;
print "handle failed!<BR>\nReason: $reason<BR>\nDescription:
$description<BR>\n" ;
exit ;
}
//
// For the second parameter to imagick_setcompression(), use one of
// these:
//
// IMAGICK_COMPRESSION_UNDEFINED
// IMAGICK_COMPRESSION_NONE
// IMAGICK_COMPRESSION_BZIP
// IMAGICK_COMPRESSION_FAX
// IMAGICK_COMPRESSION_GROUP4
// IMAGICK_COMPRESSION_JPEG
// IMAGICK_COMPRESSION_LOSSLESSJPEG
// IMAGICK_COMPRESSION_LZW
// IMAGICK_COMPRESSION_RLE
// IMAGICK_COMPRESSION_ZIP
//
imagick_setcompression( $handle, IMAGICK_COMPRESSION_LOSSLESSJPEG ) ;
if ( !imagick_writeimage( $handle, "./new_image.jpg" ) )
{
$reason = imagick_failedreason( $handle ) ;
$description = imagick_faileddescription( $handle ) ;
print "imagick_writeimage() failed<BR>\nReason:
$reason<BR>\nDescription: $description<BR>\n" ;
exit ;
}
header( "Location: images_jpg.html" ) ;
?>