cvs: pecl /imagick imagick.c package.xml php_imagick.h /imagick/examples transparent.php

From: Date: Mon, 05 Jan 2004 22:01:36 +0000
Subject: cvs: pecl /imagick imagick.c package.xml php_imagick.h /imagick/examples transparent.php
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-647@lists.php.net to get a copy of this message
mcmontero Mon Jan 5 17:01:36 2004 EDT Added files: /pecl/imagick/examples transparent.php Modified files: /pecl/imagick imagick.c package.xml php_imagick.h Log: - added function imagick_transparent() for setting a particular color to be transparent within an image. Index: pecl/imagick/imagick.c diff -u pecl/imagick/imagick.c:1.48 pecl/imagick/imagick.c:1.49 --- pecl/imagick/imagick.c:1.48 Tue Oct 7 14:30:19 2003 +++ pecl/imagick/imagick.c Mon Jan 5 17:01:35 2004 @@ -16,7 +16,7 @@ | Christian Stocker (chregu@bitflux.ch) | +----------------------------------------------------------------------+ - $Id: imagick.c,v 1.48 2003/10/07 18:30:19 mcmontero Exp $ + $Id: imagick.c,v 1.49 2004/01/05 22:01:35 mcmontero Exp $ */ #ifdef HAVE_CONFIG_H @@ -226,6 +226,7 @@ PHP_FE( imagick_rgbtransform, NULL ) PHP_FE( imagick_transformrgb, NULL ) PHP_FE( imagick_mosaic, NULL ) + PHP_FE( imagick_transparent, NULL ) /***** @@ -5168,6 +5169,52 @@ RETURN_RESOURCE( mosaic_handle->id ) ; } +PHP_FUNCTION( imagick_transparent ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + char* trans_color ; /* the color to make transparent */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + PixelPacket target ; /* the target transparent pixel */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rs", + &handle_id, &trans_color ) == 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 ) ; + + target = AcquireOnePixel( handle->image, 0, 0, &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + ( void )QueryColorDatabase( trans_color, &target, &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + ( void )TransparentImage( handle->image, target, TransparentOpacity ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + /*****************************************************************************/ /****************************************************************************** Index: pecl/imagick/package.xml diff -u pecl/imagick/package.xml:1.63 pecl/imagick/package.xml:1.64 --- pecl/imagick/package.xml:1.63 Tue Oct 7 14:30:19 2003 +++ pecl/imagick/package.xml Mon Jan 5 17:01:35 2004 @@ -31,6 +31,8 @@ of an image. - function imagick_setcompressiontype() was not setting the correct structure. This was identified and tested by Sergio Salvatore (sergio@cucinalogica.com). +- added function imagick_transparent() for setting a particular color to be + transparent within an image. </notes> <state>beta</state> </release> Index: pecl/imagick/php_imagick.h diff -u pecl/imagick/php_imagick.h:1.27 pecl/imagick/php_imagick.h:1.28 --- pecl/imagick/php_imagick.h:1.27 Thu Sep 18 12:02:18 2003 +++ pecl/imagick/php_imagick.h Mon Jan 5 17:01:35 2004 @@ -16,7 +16,7 @@ | Christian Stocker (chregu@bitflux.ch) | +----------------------------------------------------------------------+ - $Id: php_imagick.h,v 1.27 2003/09/18 16:02:18 mcmontero Exp $ + $Id: php_imagick.h,v 1.28 2004/01/05 22:01:35 mcmontero Exp $ */ #ifndef PHP_IMAGICK_H @@ -240,6 +240,7 @@ PHP_FUNCTION( imagick_rgbtransform ) ; PHP_FUNCTION( imagick_transformrgb ) ; PHP_FUNCTION( imagick_mosaic ) ; + PHP_FUNCTION( imagick_transparent ) ; /***** Index: pecl/imagick/examples/transparent.php +++ pecl/imagick/examples/transparent.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 ; } if ( !imagick_transparent( $handle, "#ff0000" ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_trim() failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } 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" ) ; ?>

« previous php.pecl.cvs (#647) next »