cvs: pear /PECL/imagick CREDITS INSTALL Makefile.in TODO config.m4 imagick.c imagick.h package.xml php_imagick.h /PECL/imagick/examples animated.gif
animatedgif2jpgs.php annotate.php arc.php blob2image.php blur.php border.php charcoal.php circle.php clone_handle.php contrast.php convert1.php
convert2.php convert_and_resize.php despeckle.php destroyhandle.php edge.php ellipse.php emboss.php enhance.php equalize.php first.php gamma.php
gaussianblur.php getcanvas.php getlistindex.php getlistsize.php getmimetype.php goto.php image.jpg image2blob.php implode.php level.php line.php
list1.php list2.php medianfilter.php modulate.php motionblur.php negate.php normalize.php oilpaint.php point.php raise.php rectangle.php
reducenoise.php rotate.php setfillcolor.php setfontface.php shade.php sharpen.php shear.php solarize.php spread.php swirl.php threshold.php
unsharpmask.php wave.php

From: Date: Mon, 02 Dec 2002 21:25:23 +0000
Subject: cvs: pear /PECL/imagick CREDITS INSTALL Makefile.in TODO config.m4 imagick.c imagick.h package.xml php_imagick.h /PECL/imagick/examples animated.gif
animatedgif2jpgs.php annotate.php arc.php blob2image.php blur.php border.php charcoal.php circle.php clone_handle.php contrast.php convert1.php
convert2.php convert_and_resize.php despeckle.php destroyhandle.php edge.php ellipse.php emboss.php enhance.php equalize.php first.php gamma.php
gaussianblur.php getcanvas.php getlistindex.php getlistsize.php getmimetype.php goto.php image.jpg image2blob.php implode.php level.php line.php
list1.php list2.php medianfilter.php modulate.php motionblur.php negate.php normalize.php oilpaint.php point.php raise.php rectangle.php
reducenoise.php rotate.php setfillcolor.php setfontface.php shade.php sharpen.php shear.php solarize.php spread.php swirl.php threshold.php
unsharpmask.php wave.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-7724@lists.php.net to get a copy of this message
chregu Mon Dec 2 16:25:23 2002 EDT Added files: /pear/PECL/imagick TODO imagick.h /pear/PECL/imagick/examples animated.gif animatedgif2jpgs.php annotate.php arc.php blob2image.php blur.php border.php charcoal.php circle.php clone_handle.php contrast.php convert1.php convert2.php convert_and_resize.php despeckle.php destroyhandle.php edge.php ellipse.php emboss.php enhance.php equalize.php first.php gamma.php gaussianblur.php getcanvas.php getlistindex.php getlistsize.php getmimetype.php goto.php image.jpg image2blob.php implode.php level.php line.php list1.php list2.php medianfilter.php modulate.php motionblur.php negate.php normalize.php oilpaint.php point.php raise.php rectangle.php reducenoise.php rotate.php setfillcolor.php setfontface.php shade.php sharpen.php shear.php solarize.php spread.php swirl.php threshold.php unsharpmask.php wave.php Modified files: /pear/PECL/imagick INSTALL Makefile.in config.m4 imagick.c package.xml php_imagick.h CREDITS Log: woho. new imagick extension is finally in PECL I have not tested this version yet and package.xml is most certainly not complete, but I trust Michael, that it's not completely borked :)

Index: pear/PECL/imagick/INSTALL diff -u /dev/null pear/PECL/imagick/INSTALL:1.4 --- /dev/null Mon Dec 2 16:25:23 2002 +++ pear/PECL/imagick/INSTALL Mon Dec 2 16:25:21 2002 @@ -0,0 +1,29 @@ +We'll assume that your PHP installation is in + /usr/src/php + +1) make sure the path to Magick-config (the ImageMagick configuration + script) is in your PATH environment variable +2) cd /usr/src/php/ext +3) untar the imagick tar +4) if the directory created is anything other then imagick, rename it to + imagick +5) cd /usr/src/php/ext/imagick +6) phpize + +If phpize produces this: + +aclocal: macro `AC_ADD_LIBPATH' defined in acinclude.m4 but never used +aclocal: macro `AC_ADD_LIBRARY_WITH_PATH' defined in acinclude.m4 but never used +aclocal: macro `AC_ADD_LIBRARY' defined in acinclude.m4 but never used +aclocal: macro `AC_ADD_INCLUDE' defined in acinclude.m4 but never used +You should update your `aclocal.m4' by running aclocal. + +Don't worry. Everything should still compile fine. + +7) cd /usr/src/php +8) ./buildconf +9) run configure as you normally would and add --with-imagick +10) make +11) make install + +You're all set. Index: pear/PECL/imagick/Makefile.in diff -u /dev/null pear/PECL/imagick/Makefile.in:1.6 --- /dev/null Mon Dec 2 16:25:23 2002 +++ pear/PECL/imagick/Makefile.in Mon Dec 2 16:25:21 2002 @@ -0,0 +1,8 @@ +# $Id: Makefile.in,v 1.6 2002/12/02 21:25:21 chregu Exp $ + +LTLIBRARY_NAME = libimagick.la +LTLIBRARY_SOURCES = imagick.c +LTLIBRARY_SHARED_NAME = imagick.la +LTLIBRARY_SHARED_LIBADD = $(IMAGICK_SHARED_LIBADD) + +include $(top_srcdir)/build/dynlib.mk Index: pear/PECL/imagick/config.m4 diff -u /dev/null pear/PECL/imagick/config.m4:1.7 --- /dev/null Mon Dec 2 16:25:23 2002 +++ pear/PECL/imagick/config.m4 Mon Dec 2 16:25:21 2002 @@ -0,0 +1,75 @@ +dnl +dnl $Id: config.m4,v 1.7 2002/12/02 21:25:21 chregu Exp $ +dnl + +PHP_ARG_WITH(imagick, for imagick support, +Make sure that the comment is aligned: +[ --with-imagick[=DIR] Include imagick support]) + +if test "$PHP_IMAGICK" != "no"; then + if test -r $PHP_IMAGICK/include/magick/magick.h; then + IMAGEMAGICK_DIR=$PHP_IMAGICK + else + AC_MSG_CHECKING(for ImageMagick in default path) + for i in /usr/local /usr; do + if test -r $i/include/magick/magick.h; then + IMAGEMAGICK_DIR=$i + AC_MSG_RESULT(found in $i) + fi + done + + dnl red hat has some strange locations for their imagemagick files + dnl so here's for redhat + + if test -z "$IMAGEMAGICK_DIR"; then + for i in /usr/local/X11R6 /usr/X11R6; do + if test -r $i/include/X11/magick/magick.h; then + IMAGEMAGICK_DIR=$i + AC_MSG_RESULT(found in $i) + fi + done + fi + fi + + if test -z "$IMAGEMAGICK_DIR"; then + AC_MSG_RESULT(not found) + AC_MSG_ERROR(Please reinstall the ImageMagick distribution - + magick.h should be in <imagemagick-dir>/include/magick/) + fi + IMAGEMAGICK_CONFIG="Magick-config" + AC_MSG_CHECKING(for ImageMagick 5.4.5 or greater) + + if ${IMAGEMAGICK_DIR}/bin/Magick-config --libs print > /dev/null 2>&1; then + IMAGEMAGICK_CONFIG=${IMAGEMAGICK_DIR}/bin/Magick-config + else + if ${IMAGEMAGICK_DIR}/Magick-config --libs print > /dev/null 2>&1; then + IMAGEMAGICK_CONFIG=${IMAGEMAGICK_DIR}/Magick-config + fi + fi + + imagemagick_version_full=`$IMAGEMAGICK_CONFIG --version` + imagemagick_version=`echo ${imagemagick_version_full} | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'` + AC_MSG_RESULT($imagemagick_version_full) + if test "$imagemagick_version" -ge 5004005; then + IMAGEMAGICK_LIBS=`$IMAGEMAGICK_CONFIG --libs` + IMAGEMAGICK_LDFLAGS=`$IMAGEMAGICK_CONFIG --ldflags` + else + AC_MSG_ERROR(ImageMagick version 5.4.5 or later is required to compile php with imagick support) + fi + + PHP_ADD_INCLUDE($IMAGEMAGICK_DIR/include) + PHP_EVAL_LIBLINE($IMAGEMAGICK_LIBS, IMAGICK_SHARED_LIBADD) + PHP_EVAL_LIBLINE($IMAGEMAGICK_LDFLAGS, IMAGICK_SHARED_LIBADD) + + AC_CHECK_LIB(Magick,InitializeMagick, + [ + AC_DEFINE(HAVE_IMAGICK,1,[ ]) + ],[ + AC_MSG_ERROR(There is something wrong. Please check config.log for more information.) + ],[ + $IMAGEMAGICK_LIBS -L$IMAGEMAGICK_DIR/lib $IMAGEMAGICK_LDFLAGS + ]) + + PHP_EXTENSION(imagick, $ext_shared) + PHP_SUBST(IMAGICK_SHARED_LIBADD) +fi Index: pear/PECL/imagick/imagick.c diff -u /dev/null pear/PECL/imagick/imagick.c:1.13 --- /dev/null Mon Dec 2 16:25:23 2002 +++ pear/PECL/imagick/imagick.c Mon Dec 2 16:25:21 2002 @@ -0,0 +1,3978 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 4 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2002 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Michael Montero (mmontero@mail.communityconnect.com) | + | Christian Stocker (chregu@bitflux.ch) | + +----------------------------------------------------------------------+ + + $Id: imagick.c,v 1.13 2002/12/02 21:25:21 chregu Exp $ +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "ext/standard/php_smart_str.h" +#include "php_imagick.h" +#include "imagick.h" + +ZEND_DECLARE_MODULE_GLOBALS( imagick ) ; + +/* True global resources - no need for thread safety here */ +static int le_imagick ; +static int le_handle ; + +zend_function_entry imagick_functions[] = +{ + /***** + + Constitute an image. + + *****/ + + PHP_FE( imagick_readimage, NULL ) + PHP_FE( imagick_writeimage, NULL ) + PHP_FE( imagick_writeimages, NULL ) + PHP_FE( imagick_clonehandle, NULL ) + PHP_FE( imagick_image2blob, NULL ) + PHP_FE( imagick_blob2image, NULL ) + PHP_FE( imagick_getcanvas, NULL ) + + /***** + + Error handling. + + *****/ + + PHP_FE( imagick_iserror, NULL ) + PHP_FE( imagick_failedreason, NULL ) + PHP_FE( imagick_faileddescription, NULL ) + + /***** + + Getting information about an image. + + *****/ + + PHP_FE( imagick_getwidth, NULL ) + PHP_FE( imagick_getheight, NULL ) + PHP_FE( imagick_getmimetype, NULL ) + + /***** + + Convert an image. + + *****/ + + PHP_FE( imagick_convert, NULL ) + + /***** + + Resize an image. + + *****/ + + PHP_FE( imagick_resize, NULL ) + PHP_FE( imagick_magnify, NULL ) + PHP_FE( imagick_minify, NULL ) + PHP_FE( imagick_scale, NULL ) + PHP_FE( imagick_sample, NULL ) + + /***** + + Font settings. + + *****/ + + PHP_FE( imagick_setfontsize, NULL ) + PHP_FE( imagick_setfontstyle, NULL ) + PHP_FE( imagick_setfontface, NULL ) + + /***** + + Draw on an image. + + *****/ + + PHP_FE( imagick_begindraw, NULL ) + PHP_FE( imagick_drawannotation, NULL ) + PHP_FE( imagick_drawrectangle, NULL ) + PHP_FE( imagick_drawellipse, NULL ) + PHP_FE( imagick_drawarc, NULL ) + PHP_FE( imagick_drawcircle, NULL ) + PHP_FE( imagick_drawline, NULL ) + PHP_FE( imagick_drawpoint, NULL ) + PHP_FE( imagick_setfillcolor, NULL ) + + /***** + + Enhance an image. + + *****/ + + PHP_FE( imagick_rotate, NULL ) + PHP_FE( imagick_shear, NULL ) + PHP_FE( imagick_contrast, NULL ) + PHP_FE( imagick_equalize, NULL ) + PHP_FE( imagick_gamma, NULL ) + PHP_FE( imagick_level, NULL ) + PHP_FE( imagick_modulate, NULL ) + PHP_FE( imagick_negate, NULL ) + PHP_FE( imagick_normalize, NULL ) + + /***** + + Decorate an image. + + *****/ + + PHP_FE( imagick_border, NULL ) + PHP_FE( imagick_frame, NULL ) + PHP_FE( imagick_raise, NULL ) + + /***** + + Special effects. + + *****/ + + PHP_FE( imagick_charcoal, NULL ) + PHP_FE( imagick_implode, NULL ) + PHP_FE( imagick_oilpaint, NULL ) + PHP_FE( imagick_solarize, NULL ) + PHP_FE( imagick_swirl, NULL ) + PHP_FE( imagick_wave, NULL ) + + /***** + + Image effects. + + *****/ + + PHP_FE( imagick_blur, NULL ) + PHP_FE( imagick_despeckle, NULL ) + PHP_FE( imagick_edge, NULL ) + PHP_FE( imagick_emboss, NULL ) + PHP_FE( imagick_enhance, NULL ) + PHP_FE( imagick_gaussianblur, NULL ) + PHP_FE( imagick_medianfilter, NULL ) + PHP_FE( imagick_motionblur, NULL ) + PHP_FE( imagick_reducenoise, NULL ) + PHP_FE( imagick_shade, NULL ) + PHP_FE( imagick_sharpen, NULL ) + PHP_FE( imagick_spread, NULL ) + PHP_FE( imagick_threshold, NULL ) + PHP_FE( imagick_unsharpmask, NULL ) + + /***** + + Image list manipulation. + + *****/ + + PHP_FE( imagick_next, NULL ) + PHP_FE( imagick_prev, NULL ) + PHP_FE( imagick_first, NULL ) + PHP_FE( imagick_goto, NULL ) + PHP_FE( imagick_getlistsize, NULL ) + PHP_FE( imagick_getlistindex, NULL ) + PHP_FE( imagick_getimagefromlist, NULL ) + + /***** + + Clean up. + + *****/ + + PHP_FE( imagick_destroyhandle, NULL ) + + /***** + + Backward compatibility with old imagick extension. + + *****/ + + PHP_FE( imagick_read, NULL ) + PHP_FE( imagick_free, NULL ) + + /***** + + Deprecated functions from old imagick extension. + + *****/ + + PHP_FE( imagick_add_resource, NULL ) + PHP_FE( imagick_list_magickinfo, NULL ) + PHP_FE( imagick_new, NULL ) + PHP_FE( imagick_init, NULL ) + PHP_FE( imagick_copy_sample, NULL ) + PHP_FE( imagick_copy_resize, NULL ) + PHP_FE( imagick_copy_crop, NULL ) + PHP_FE( imagick_copy_shear, NULL ) + PHP_FE( imagick_copy_rotate, NULL ) + PHP_FE( imagick_copy_morph, NULL ) + PHP_FE( imagick_dump, NULL ) + + /***** + + Aliases + + *****/ + + PHP_FALIAS( imagick_write, imagick_writeimage, NULL ) + + {NULL, NULL, NULL} +} ; + +zend_module_entry imagick_module_entry = +{ + STANDARD_MODULE_HEADER, + "imagick", + imagick_functions, + PHP_MINIT( imagick ), + NULL, + PHP_RINIT( imagick ), + PHP_RSHUTDOWN( imagick ), + PHP_MINFO( imagick ), + IMAGICK_VERSION, + STANDARD_MODULE_PROPERTIES +} ; + +#ifdef COMPILE_DL_IMAGICK + ZEND_GET_MODULE( imagick ) +#endif + +PHP_MINIT_FUNCTION( imagick ) +{ + le_handle = zend_register_list_destructors_ex( + _php_imagick_free_handle_list, NULL, + "imagemagick handle", module_number ) ; + + /***** + + Register the filter types. These values are taken from + magick/classify.h in the ImageMagick API. The enumeration is + called FilterTypes. + + *****/ + + REGISTER_LONG_CONSTANT( "IMAGICK_FILTER_UNKNOWN", UndefinedFilter, + CONST_CS | CONST_PERSISTENT ) ; + REGISTER_LONG_CONSTANT( "IMAGICK_FILTER_POINT", PointFilter, + CONST_CS | CONST_PERSISTENT ) ; + REGISTER_LONG_CONSTANT( "IMAGICK_FILTER_BOX", BoxFilter, + CONST_CS | CONST_PERSISTENT ) ; + REGISTER_LONG_CONSTANT( "IMAGICK_FILTER_TRIANGLE", TriangleFilter, + CONST_CS | CONST_PERSISTENT ) ; + REGISTER_LONG_CONSTANT( "IMAGICK_FILTER_HERMITE", HermiteFilter, + CONST_CS | CONST_PERSISTENT ) ; + REGISTER_LONG_CONSTANT( "IMAGICK_FILTER_HANNING", HanningFilter, + CONST_CS | CONST_PERSISTENT ) ; + REGISTER_LONG_CONSTANT( "IMAGICK_FILTER_HAMMING", HammingFilter, + CONST_CS | CONST_PERSISTENT ) ; + REGISTER_LONG_CONSTANT( "IMAGICK_FILTER_BLACKMAN", BlackmanFilter, + CONST_CS | CONST_PERSISTENT ) ; + REGISTER_LONG_CONSTANT( "IMAGICK_FILTER_GAUSSIAN", GaussianFilter, + CONST_CS | CONST_PERSISTENT ) ; + REGISTER_LONG_CONSTANT( "IMAGICK_FILTER_QUADRATIC", QuadraticFilter, + CONST_CS | CONST_PERSISTENT ) ; + REGISTER_LONG_CONSTANT( "IMAGICK_FILTER_CUBIC", CubicFilter, + CONST_CS | CONST_PERSISTENT ) ; + REGISTER_LONG_CONSTANT( "IMAGICK_FILTER_CATROM", CatromFilter, + CONST_CS | CONST_PERSISTENT ) ; + REGISTER_LONG_CONSTANT( "IMAGICK_FILTER_MITCHELL", MitchellFilter, + CONST_CS | CONST_PERSISTENT ) ; + REGISTER_LONG_CONSTANT( "IMAGICK_FILTER_LANCZOS", LanczosFilter, + CONST_CS | CONST_PERSISTENT ) ; + REGISTER_LONG_CONSTANT( "IMAGICK_FILTER_BESSEL", BesselFilter, + CONST_CS | CONST_PERSISTENT ) ; + REGISTER_LONG_CONSTANT( "IMAGICK_FILTER_SINC", SincFilter, + CONST_CS | CONST_PERSISTENT ) ; + + /***** + + Register the font styles. These values are taken from + magick/classify.h in the ImageMagick API. The enumeration is + called StyleType. + + *****/ + + REGISTER_LONG_CONSTANT( "IMAGICK_FONTSTYLE_NORMAL", NormalStyle, + CONST_CS | CONST_PERSISTENT ) ; + REGISTER_LONG_CONSTANT( "IMAGICK_FONTSTYLE_ITALIC", ItalicStyle, + CONST_CS | CONST_PERSISTENT ) ; + REGISTER_LONG_CONSTANT( "IMAGICK_FONTSTYLE_OBLIQUE", ObliqueStyle, + CONST_CS | CONST_PERSISTENT ) ; + REGISTER_LONG_CONSTANT( "IMAGICK_FONTSTYLE_ANY", AnyStyle, + CONST_CS | CONST_PERSISTENT ) ; + + /***** + + Register constants for raising/lowering an image when calling + imagick_raise(). + + *****/ + + REGISTER_LONG_CONSTANT( "IMAGICK_RAISE", 1, + CONST_CS | CONST_PERSISTENT ) ; + REGISTER_LONG_CONSTANT( "IMAGICK_LOWER", 0, + CONST_CS | CONST_PERSISTENT ) ; + + return SUCCESS ; +} + +PHP_RINIT_FUNCTION( imagick ) +{ + IMAGICK_G( imagick_was_init ) = 0 ; + + return SUCCESS ; +} + +PHP_RSHUTDOWN_FUNCTION( imagick ) +{ + if ( IMAGICK_G( imagick_was_init ) == 1 ) + { + DestroyMagick() ; + } + + return SUCCESS ; +} + +PHP_MINFO_FUNCTION( imagick ) +{ + const MagickInfo* magick_info ; + const register MagickInfo* p ; + const TypeInfo* type_info ; + ExceptionInfo exception ; + char buffer[ 512 ] ; + smart_str format_list = { 0 } ; + + php_info_print_table_start() ; + php_info_print_table_header( 2, "ImageMagick support", "enabled" ) ; + php_info_print_table_row( 2, "ImageMagick version", + MagickLibVersionText ) ; + php_info_print_table_row( 2, "PHP imagick version", IMAGICK_VERSION ) ; + + snprintf( buffer, 512, "%ld\0", MaxRGB ) ; + php_info_print_table_row( 2, "MaxRGB", buffer ) ; + + /***** + + Get the list of available image formats. + + *****/ + + magick_info = GetMagickInfo( NULL, &exception ) ; + if ( magick_info != ( MagickInfo* )NULL ) + { + for ( p = magick_info ; p != ( MagickInfo* )NULL ; p = p->next ) + { + smart_str_appendl( &format_list, p->name, + strlen( p->name ) ) ; + if ( p->next ) + { + smart_str_appendl( &format_list, ", ", 2 ) ; + } + } + + smart_str_0( &format_list ) ; + php_info_print_table_row( 2, "Supported image formats", + format_list.c ) ; + } + else + { + php_error( E_WARNING, "%s(): magick_info struct is NULL after call to GetMagickInfo()", get_active_function_name( TSRMLS_C ) ) ; + } + + /***** + + Get a list of the available font names. + + *****/ + + type_info = GetTypeInfo( "*", &exception ) ; + if ( type_info != ( TypeInfo* )NULL ) + { + while( type_info ) + { + snprintf( buffer, 512, "%s - %s\0", type_info->family, + type_info->name ) ; + php_info_print_table_row( 2, "Font Family - Name", + buffer ) ; + + type_info = type_info->next ; + } + } + else + { + php_error( E_WARNING, "%s(): type_info struct is NULL after call to GetTypeInfo()", get_active_function_name( TSRMLS_C ) ) ; + } + + php_info_print_table_end(); +} + +/****************************************************************************** + * + * Constitute an image. + * + */ + +PHP_FUNCTION( imagick_readimage ) +{ + char* file_name ; /* the file name to use to retrieve + the image */ + int file_name_len ; /* the length of the file name */ + imagick_t* handle ; /* the handle for this image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s", + &file_name, &file_name_len ) == FAILURE ) + { + return ; + } + + handle = _php_imagick_readimage( file_name ) ; + RETURN_RESOURCE( handle->id ) ; +} + +PHP_FUNCTION( imagick_writeimage ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + char* file_name ; /* the location to which to write out + the image */ + int file_name_len ; /* the length of the file name */ + imagick_t* handle ; /* the handle for this image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rs", + &handle_id, &file_name, &file_name_len ) == 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_info ) + { + php_error( E_WARNING, "%s(): image_info is empty ", + get_active_function_name( TSRMLS_C ) ) ; + RETURN_FALSE ; + } + + if ( !handle->image ) + { + php_error( E_WARNING, "%s(): image is empty", + get_active_function_name( TSRMLS_C ) ) ; + RETURN_FALSE ; + } + + if ( file_name_len >= MaxTextExtent ) + { + php_error( E_WARNING, "%s(): file name is too long", + get_active_function_name( TSRMLS_C ) ) ; + RETURN_FALSE ; + } + + strncpy( handle->image->filename, file_name, MaxTextExtent - 1 ) ; + + if ( !WriteImage( handle->image_info, handle->image ) ) + { + ThrowException( &handle->exception, FileOpenError, + "could not write to file in _php_imagick_writeimage()", + file_name ) ; + RETURN_FALSE ; + } + + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_writeimages ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + char* file_name ; /* the location to which to write out + the image */ + int file_name_len ; /* the length of the file name */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rs", + &handle_id, &file_name, &file_name_len ) == 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_info ) + { + php_error( E_WARNING, "%s(): image_info is empty ", + get_active_function_name( TSRMLS_C ) ) ; + RETURN_FALSE ; + } + + if ( !handle->image ) + { + php_error( E_WARNING, "%s(): image is empty", + get_active_function_name( TSRMLS_C ) ) ; + RETURN_FALSE ; + } + + if ( file_name_len >= MaxTextExtent ) + { + php_error( E_WARNING, "%s(); file name is too long", + get_active_function_name( TSRMLS_C ) ) ; + RETURN_FALSE ; + } + + if ( !WriteImages( handle->image_info, handle->image, file_name, + &handle->exception ) ) + { + ThrowException( &handle->exception, FileOpenError, + "could not write to file in imagick_writeimages()", + file_name ) ; + RETURN_FALSE ; + } + + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_clonehandle ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + imagick_t* new_handle ; /* the new, cloned handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ) ; + + new_handle = _php_imagick_alloc_handle() ; + if ( !new_handle ) + { + RETURN_FALSE ; + } + + if ( handle->image ) + { + if ( GetImageListSize( handle->image ) <= 1 ) + { + /***** + + This is a single image, not a list. + + *****/ + + new_handle->image = CloneImage( handle->image, 0, 0, 1, + &handle->exception ) ; + } + else + { + new_handle->image = CloneImageList( handle->image, + &handle->exception ) ; + } + + if ( _php_imagick_is_error( handle ) ) + { + _php_imagick_clean_up_handle( new_handle ) ; + RETURN_FALSE ; + } + } + + /***** + + _php_imagick_alloc_handle() already created a NULL image_info + structure. We want to safely clean that up before assigning the + new one. + + *****/ + + if ( new_handle->image_info ) + { + DestroyImageInfo( new_handle->image_info ) ; + } + new_handle->image_info = CloneImageInfo( handle->image_info ) ; + + new_handle->id = zend_list_insert( new_handle, le_handle ) ; + RETURN_RESOURCE( new_handle->id ) ; +} + +PHP_FUNCTION( imagick_image2blob ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + void* blob_data ; /* the image BLOB data */ + size_t blob_size ; /* the size of the image BLOB */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ) + { + ThrowException( &handle->exception, FatalErrorException, + "image is empty in imagick_image2blob()", NULL ) ; + RETURN_FALSE ; + } + + blob_data = ImageToBlob( handle->image_info, handle->image, + &blob_size, &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( blob_data ) + { + /***** + + ImageMagick allocated this memory using malloc(), + so we'll free it just to make sure. + + *****/ + + free( blob_data ) ; + } + + RETURN_FALSE ; + } + + if ( !blob_data ) + { + ThrowException( &handle->exception, FatalErrorException, "blob_data is empty in imagick_image2blob() after call to ImageToBlob()", NULL ) ; + RETURN_FALSE ; + } + + RETURN_STRINGL( ( char* )blob_data, blob_size, 1 ) ; +} + +PHP_FUNCTION( imagick_blob2image ) +{ + char* blob_data ; /* the blob data to use to create the + image */ + long blob_data_len ; /* string length of blob_data */ + imagick_t* handle ; /* the handle for this image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s", + &blob_data, &blob_data_len ) == FAILURE ) + { + return ; + } + + if ( IMAGICK_G( imagick_was_init ) == 0 ) + { + /***** + + Initialize the ImageMagick engine. + + *****/ + + _php_imagick_init() ; + } + + handle = _php_imagick_alloc_handle() ; + if ( !handle ) + { + RETURN_FALSE ; + } + handle->id = zend_list_insert( handle, le_handle ) ; + + handle->image = BlobToImage( handle->image_info, ( void* )blob_data, + blob_data_len, &handle->exception ) ; + RETURN_RESOURCE( handle->id ) ; +} + +PHP_FUNCTION( imagick_getcanvas ) +{ + char* color ; /* the color of the canvas */ + int color_len ; /* the length of the color */ + long width ; /* the width of the canvas */ + long height ; /* the height of the canvas */ + imagick_t* handle ; /* the handle for this image */ + char buffer[ MaxTextExtent ] ; /* buffer for creating + strings */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "sll", + &color, &color_len, &width, &height ) == FAILURE ) + { + return ; + } + + if ( IMAGICK_G( imagick_was_init ) == 0 ) + { + /***** + + Initialize the ImageMagick engine. + + *****/ + + _php_imagick_init() ; + } + + handle = _php_imagick_alloc_handle() ; + if ( !handle ) + { + RETURN_FALSE ; + } + handle->id = zend_list_insert( handle, le_handle ) ; + + FormatString( buffer, "%ldx%ld", width, height ) ; + CloneString( &handle->image_info->size, buffer ) ; + + FormatString( buffer, "xc:%s\0", color ) ; + strncpy( handle->image_info->filename, buffer, strlen( buffer ) ) ; + + handle->image = ReadImage( handle->image_info, &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_RESOURCE( handle->id ) ; + } + + if ( !handle->image ) + { + ThrowException( &handle->exception, FatalErrorException, + "after ReadImage(), image is empty imagick_getcanvas()", + NULL ) ; + RETURN_RESOURCE( handle->id ) ; + } + + RETURN_RESOURCE( handle->id ) ; +} + +/*****************************************************************************/ + +/****************************************************************************** + * + * Error handling. + * + */ + +PHP_FUNCTION( imagick_iserror ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ; + } + + if ( _php_imagick_is_error( handle ) ) + { + RETURN_TRUE ; + } + + RETURN_FALSE ; +} + +PHP_FUNCTION( imagick_failedreason ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ; + } + + if ( handle->exception.reason ) + { + RETURN_STRINGL( handle->exception.reason, + strlen( handle->exception.reason ), 1 ) ; + } + + if ( handle->image->exception.reason ) + { + RETURN_STRINGL( handle->image->exception.reason, + strlen( handle->image->exception.reason ), + 1 ) ; + } + + RETURN_FALSE ; +} + +PHP_FUNCTION( imagick_faileddescription ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ; + } + + if ( handle->exception.description ) + { + RETURN_STRINGL( handle->exception.description, + strlen( handle->exception.description ), 1 ) ; + } + + if ( handle->image->exception.description ) + { + RETURN_STRINGL( handle->image->exception.description, + strlen( handle->image->exception.description ), + 1 ) ; + } + + RETURN_FALSE ; +} + +/*****************************************************************************/ + +/****************************************************************************** + * + * Getting information about an image. + * + */ + +PHP_FUNCTION( imagick_getwidth ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ) ; + + RETURN_LONG( handle->image->columns ) ; +} + +PHP_FUNCTION( imagick_getheight ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ) ; + + RETURN_LONG( handle->image->rows ) ; +} + +PHP_FUNCTION( imagick_getmimetype ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + char* mime_type ; /* the image MIME type */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ) ; + + mime_type = MagickToMime( handle->image->magick ) ; + RETURN_STRINGL( mime_type, strlen( mime_type ), 1 ) ; +} + +/*****************************************************************************/ + +/****************************************************************************** + * + * Convert an image. + * + */ + +PHP_FUNCTION( imagick_convert ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + char* type ; /* the image type to convert to - + execute "convert -list format" and + use the rightmost column for this + value */ + int type_len ; /* length of the type string */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rs", + &handle_id, &type, &type_len ) == 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 ) + { + php_error( E_WARNING, "%s(): image is empty", + get_active_function_name( TSRMLS_C ) ) ; + RETURN_FALSE ; + } + + if ( type_len >= MaxTextExtent ) + { + php_error( E_WARNING, "%s(): type is too long", + get_active_function_name( TSRMLS_C ) ) ; + RETURN_FALSE ; + } + + strncpy( handle->image->magick, type, MaxTextExtent - 1 ) ; + + /***** + + Note, when the image is written or transferred to a BLOB it will + be rendered as the type specified. + + *****/ + + RETURN_TRUE ; +} + +/*****************************************************************************/ + +/****************************************************************************** + * + * Resize an image. + * + */ + +PHP_FUNCTION( imagick_resize ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + long cols ; /* the number of columns to resize to */ + long rows ; /* the number of rows to resize to */ + long filter ; /* the filter type to use when re- + sizing - one of IMAGICK_FILTER_* */ + double blur ; /* the factor where > 1 is blurry, + < 1 is sharp */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, resized image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rllld", + &handle_id, &cols, &rows, &filter, &blur ) == 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 ) ; + + new_image = ResizeImage( handle->image, cols, rows, + ( FilterTypes )filter, blur, + &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + + RETURN_FALSE ; + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_magnify ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, magnified image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ) ; + + new_image = MagnifyImage( handle->image, &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + + RETURN_FALSE ; + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_minify ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, minified image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ) ; + + new_image = MinifyImage( handle->image, &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + + RETURN_FALSE ; + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_scale ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + long cols ; /* the number of columns to scale to */ + long rows ; /* the number of rows to scale to */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, minified image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rll", + &handle_id, &cols, &rows ) == 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 ) ; + + new_image = ScaleImage( handle->image, cols, rows, + &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + + RETURN_FALSE ; + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_sample ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + long cols ; /* the number of columns to scale to */ + long rows ; /* the number of rows to scale to */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, minified image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rll", + &handle_id, &cols, &rows ) == 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 ) ; + + new_image = SampleImage( handle->image, cols, rows, + &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + + RETURN_FALSE ; + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +/*****************************************************************************/ + +/****************************************************************************** + * + * Font settings. + * + */ + +PHP_FUNCTION( imagick_setfontsize ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double size ; /* pointsize for font */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rd", + &handle_id, &size ) == 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 ; + } + + if ( !handle->draw_info || !handle->draw_context ) + { + ThrowException( &handle->exception, WarningException, + "you must call imagick_begindraw() first", NULL ) ; + RETURN_FALSE ; + } + + _php_imagick_clear_errors( handle ) ; + + DrawSetFontSize( handle->draw_context, size ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_setfontstyle ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + long style ; /* the font style - one of + IMAGICK_FONTSTYLE_* */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rl", + &handle_id, &style ) == 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->draw_info || !handle->draw_context ) + { + ThrowException( &handle->exception, WarningException, + "you must call imagick_begindraw() first", NULL ) ; + RETURN_FALSE ; + } + + DrawSetFontStyle( handle->draw_context, ( StyleType )style ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_setfontface ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + char* face ; /* the font face to use; see phpinfo() + for available fonts */ + int face_len ; /* string length of face */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rs", + &handle_id, &face, &face_len ) == 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->draw_info || !handle->draw_context ) + { + ThrowException( &handle->exception, WarningException, + "you must call imagick_begindraw() first", NULL ) ; + RETURN_FALSE ; + } + + DrawSetFont( handle->draw_context, face ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +/*****************************************************************************/ + +/****************************************************************************** + * + * Draw on an image. + * + */ + +PHP_FUNCTION( imagick_begindraw ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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_info && !handle->draw_info ) + { + handle->draw_info = CloneDrawInfo( handle->image_info, + ( DrawInfo* )NULL ) ; + if ( !handle->draw_info ) + { + php_error( E_ERROR, "%s(): CloneDrawInfo did not properly allocate DrawInfo structure", get_active_function_name( TSRMLS_C ) ) ; + RETURN_FALSE ; + } + } + else + { + php_error( E_WARNING, "%s(): attempt to create draw_info with CloneDrawInfo() and empty image_info", get_active_function_name( TSRMLS_C ) ) ; + } + + if ( handle->draw_info && handle->image && !handle->draw_context ) + { + handle->draw_context = DrawAllocateContext( handle->draw_info, + handle->image ) ; + if ( !handle->draw_context ) + { + php_error( E_ERROR, "%s(): DrawAllocateContext() did not properly allocate DrawContext structure", get_active_function_name( TSRMLS_C ) ) ; + RETURN_FALSE ; + } + } + else + { + php_error( E_WARNING, "%s(): attempt to create draw_context with DrawAllocateContext() and empty draw_info or image", get_active_function_name( TSRMLS_C ) ) ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_drawannotation ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double coord_x ; /* X coordinate to begin drawing text */ + double coord_y ; /* Y coordinate to begin drawing text */ + char* text ; /* the text to draw */ + int text_len ; /* string length of text */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rdds", + &handle_id, &coord_x, &coord_y, &text, &text_len ) + == 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->draw_info || !handle->draw_context ) + { + ThrowException( &handle->exception, WarningException, + "you must call imagick_begindraw() first", NULL ) ; + RETURN_FALSE ; + } + + DrawAnnotation( handle->draw_context, coord_x, coord_y, text ) ; + + DrawRender( handle->draw_context ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_drawrectangle ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double coord_x1 ; /* x of upper left */ + double coord_y1 ; /* y of upper left */ + double coord_x2 ; /* x of lower right */ + double coord_y2 ; /* y of lower right */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rdddd", + &handle_id, &coord_x1, &coord_y1, &coord_x2, + &coord_y2 ) == 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->draw_info || !handle->draw_context ) + { + ThrowException( &handle->exception, WarningException, + "you must call imagick_begindraw() first", NULL ) ; + RETURN_FALSE ; + } + + DrawRectangle( handle->draw_context, coord_x1, coord_y1, coord_x2, + coord_y2 ) ; + + DrawRender( handle->draw_context ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_drawellipse ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double coord_x ; /* origin x coordinate */ + double coord_y ; /* origin y coordinate */ + double radius_x ; /* x radius */ + double radius_y ; /* y radius */ + double start_rot ; /* start rotation in degrees */ + double end_rot ; /* end rotation in degrees */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rdddddd", + &handle_id, &coord_x, &coord_y, &radius_x, &radius_y, + &start_rot, &end_rot ) == 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->draw_info || !handle->draw_context ) + { + ThrowException( &handle->exception, WarningException, + "you must call imagick_begindraw() first", NULL ) ; + RETURN_FALSE ; + } + + DrawEllipse( handle->draw_context, coord_x, coord_y, radius_x, + radius_y, start_rot, end_rot ) ; + + DrawRender( handle->draw_context ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_drawarc ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double coord_x1 ; /* starting x coordinate */ + double coord_y1 ; /* starting y coordinate */ + double coord_x2 ; /* ending x coordinate */ + double coord_y2 ; /* ending y coordinate */ + double start_rot ; /* start rotation in degrees */ + double end_rot ; /* end rotation in degrees */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rdddddd", + &handle_id, &coord_x1, &coord_y1, &coord_x2, &coord_y2, + &start_rot, &end_rot ) == 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->draw_info || !handle->draw_context ) + { + ThrowException( &handle->exception, WarningException, + "you must call imagick_begindraw() first", NULL ) ; + RETURN_FALSE ; + } + + DrawArc( handle->draw_context, coord_x1, coord_y1, coord_x2, + coord_y2, start_rot, end_rot ) ; + + DrawRender( handle->draw_context ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_drawcircle ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double coord_x1 ; /* origin x coordinate */ + double coord_y1 ; /* origin y coordinate */ + double coord_x2 ; /* perimater x coordinate */ + double coord_y2 ; /* perimater y coordinate */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rdddd", + &handle_id, &coord_x1, &coord_y1, &coord_x2, + &coord_y2 ) == 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->draw_info || !handle->draw_context ) + { + ThrowException( &handle->exception, WarningException, + "you must call imagick_begindraw() first", NULL ) ; + RETURN_FALSE ; + } + + DrawCircle( handle->draw_context, coord_x1, coord_y1, coord_x2, + coord_y2 ) ; + + DrawRender( handle->draw_context ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_drawline ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double coord_x1 ; /* starting x coordinate */ + double coord_y1 ; /* starting y coordinate */ + double coord_x2 ; /* ending x coordinate */ + double coord_y2 ; /* ending y coordinate */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rdddd", + &handle_id, &coord_x1, &coord_y1, &coord_x2, + &coord_y2 ) == 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->draw_info || !handle->draw_context ) + { + ThrowException( &handle->exception, WarningException, + "you must call imagick_begindraw() first", NULL ) ; + RETURN_FALSE ; + } + + DrawLine( handle->draw_context, coord_x1, coord_y1, coord_x2, + coord_y2 ) ; + + DrawRender( handle->draw_context ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_drawpoint ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double coord_x ; /* x coordinate */ + double coord_y ; /* y coordinate */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rdd", + &handle_id, &coord_x, &coord_y ) == 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->draw_info || !handle->draw_context ) + { + ThrowException( &handle->exception, WarningException, + "you must call imagick_begindraw() first", NULL ) ; + RETURN_FALSE ; + } + + DrawPoint( handle->draw_context, coord_x, coord_y ) ; + + DrawRender( handle->draw_context ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_setfillcolor ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + char* color ; /* the color in the format #ff00ff */ + int color_len ; /* string length of color */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + PixelPacket pixel_packet ; /* the struct containing the color + information */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rs", + &handle_id, &color, &color_len ) == 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->draw_info || !handle->draw_context ) + { + ThrowException( &handle->exception, WarningException, + "you must call imagick_begindraw() first", NULL ) ; + RETURN_FALSE ; + } + + if ( *color != '#' ) + { + ThrowException( &handle->exception, WarningException, + "color must be in the format \"#ffff00\"", NULL ) ; + RETURN_FALSE ; + } + + QueryColorDatabase( color, &pixel_packet, &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + DrawSetFillColor( handle->draw_context, &pixel_packet ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +/*****************************************************************************/ + +/****************************************************************************** + * + * Enhance an image. + * + */ + +PHP_FUNCTION( imagick_rotate ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double degrees ; /* the number of degrees to rotate; + positive angles rotate image + counter-clockwise, negative angles + rotate clockwise */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, rotated image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rd", + &handle_id, &degrees ) == 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 ( degrees == 0 ) + { + RETURN_TRUE ; + } + + new_image = RotateImage( handle->image, degrees, &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + + RETURN_FALSE ; + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_shear ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double coord_x ; /* x coordinate */ + double coord_y ; /* y coordinate */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, rotated image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rdd", + &handle_id, &coord_x, &coord_y ) == 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 ) ; + + new_image = ShearImage( handle->image, coord_x, coord_y, + &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + + RETURN_FALSE ; + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_contrast ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + long sharpen ; /* increase or decrease image + contrast */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rl", + &handle_id, &sharpen ) == 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 ) ; + + ContrastImage( handle->image, sharpen ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_equalize ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ) ; + + EqualizeImage( handle->image ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_gamma ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + char* level ; /* define the level of gamma + correction; values typically + range from 0.8 to 2.3 */ + int level_len ; /* string length of level */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rs", + &handle_id, &level, &level_len ) == 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 ) ; + + GammaImage( handle->image, level ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_level ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + char* level ; /* define the level of gamma + correction; values typically + range from 0.8 to 2.3 */ + int level_len ; /* string length of level */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rs", + &handle_id, &level, &level_len ) == 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 ) ; + + LevelImage( handle->image, level ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_modulate ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + char* modulate ; /* change in brightness, saturation + and hue */ + int modulate_len ; /* string length of modulate */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rs", + &handle_id, &modulate, &modulate_len ) == 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 ) ; + + ModulateImage( handle->image, modulate ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_negate ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + long gray_scale ; /* whether only the gray scale within + the image should be negated + and hue */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rl", + &handle_id, &gray_scale ) == 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 ) ; + + NegateImage( handle->image, gray_scale ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_normalize ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ) ; + + NormalizeImage( handle->image ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +/*****************************************************************************/ + +/****************************************************************************** + * + * Decorate an image. + * + */ + +PHP_FUNCTION( imagick_border ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + long coord_x ; /* x starting position of border */ + long coord_y ; /* y starting position of border */ + long width ; /* width of border */ + long height ; /* height of border */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + RectangleInfo border_info ; /* struct containing x, y, width and + height of border */ + Image* new_image ; /* the new image with the border */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rllll", + &handle_id, &coord_x, &coord_y, &width, &height ) + == 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 ) ; + + border_info.width = width ; + border_info.height = height ; + border_info.x = coord_x ; + border_info.y = coord_y ; + + new_image = BorderImage( handle->image, &border_info, + &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + + RETURN_FALSE ; + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_frame ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + long coord_x ; /* x starting position of border */ + long coord_y ; /* y starting position of border */ + long width ; /* width of border */ + long height ; /* height of border */ + long inner_bevel ; /* the inner bevel */ + long outer_bevel ; /* the outer bevel */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + FrameInfo frame_info ; /* struct containing x, y, width, + height and bevel values of border */ + Image* new_image ; /* the new image with the frame */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rllllll", + &handle_id, &coord_x, &coord_y, &width, &height, + &inner_bevel, &outer_bevel ) == 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 ) ; + + frame_info.width = width ; + frame_info.height = height ; + frame_info.x = coord_x ; + frame_info.y = coord_y ; + frame_info.inner_bevel = inner_bevel ; + frame_info.outer_bevel = outer_bevel ; + + new_image = FrameImage( handle->image, &frame_info, + &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + + RETURN_FALSE ; + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_raise ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + long coord_x ; /* x starting position of border */ + long coord_y ; /* y starting position of border */ + long width ; /* width of border */ + long height ; /* height of border */ + long raise ; /* non-zero and the image has a 3-D + raise effect, otherwise it looks + lowered */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + RectangleInfo raise_info ; /* struct containing x, y, width and + height of the raise */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rlllll", + &handle_id, &coord_x, &coord_y, &width, &height, + &raise ) == 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 ) ; + + raise_info.width = width ; + raise_info.height = height ; + raise_info.x = coord_x ; + raise_info.y = coord_y ; + + RaiseImage( handle->image, &raise_info, raise ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +/*****************************************************************************/ + +/****************************************************************************** + * + * Special effects. + * + */ + +PHP_FUNCTION( imagick_charcoal ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double radius ; /* the radius of pixel neighborhood */ + double sigma ; /* the standard deviation of the + Gaussian, in pixels */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, charcoaled image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rdd", + &handle_id, &radius, &sigma ) == 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 ) ; + + new_image = CharcoalImage( handle->image, radius, sigma, + &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + + RETURN_FALSE ; + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_implode ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double amount ; /* define the extent of the implosion */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, imploded image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rd", + &handle_id, &amount ) == 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 ) ; + + new_image = ImplodeImage( handle->image, amount, &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + + RETURN_FALSE ; + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_oilpaint ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double radius ; /* the radius of the circular + neighborhood */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, oil painted image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rd", + &handle_id, &radius ) == 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 ) ; + + new_image = OilPaintImage( handle->image, radius, &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + + RETURN_FALSE ; + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_solarize ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double threshold ; /* define the extent of solarization - + this value is between 0 and MaxRGB; + see phpinfo() for MaxRGB */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rd", + &handle_id, &threshold ) == 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 ) ; + + SolarizeImage( handle->image, threshold ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_swirl ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double degrees ; /* define the tightness of the swirling + effect */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, swirled image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rd", + &handle_id, &degrees ) == 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 ) ; + + new_image = SwirlImage( handle->image, degrees, &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + + RETURN_FALSE ; + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_wave ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double amplitude ; /* the amplitude of the wave */ + double frequency ; /* the frequency of the wave */ + imagick_t* handle ; /* the actual magick_t struct for the + handle */ + Image* new_image ; /* the new, waved image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rdd", + &handle_id, &amplitude, &frequency ) == 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 ) ; + + new_image = WaveImage( handle->image, amplitude, frequency, + &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + + RETURN_FALSE ; + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +/*****************************************************************************/ + +/****************************************************************************** + * + * Image effects. + * + */ + +PHP_FUNCTION( imagick_blur ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double radius ; /* the radius of the Gaussian, in + pixels, not counter the center + pixel */ + double sigma ; /* the standard deviation of the + Gaussian, in pixels */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, blurred image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rdd", + &handle_id, &radius, &sigma ) == 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 ) ; + + new_image = BlurImage( handle->image, radius, sigma, + &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + + RETURN_FALSE ; + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_despeckle ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, despeckled image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ) ; + + new_image = DespeckleImage( handle->image, &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_edge ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double radius ; /* the radius of the pixel neighbor- + hood; using 0 will cause a + suitable radius to be selected + for you */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rd", + &handle_id, &radius ) == 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 ) ; + + new_image = EdgeImage( handle->image, radius, &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_emboss ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double radius ; /* the radius of the pixel neighbor- + hood */ + double sigma ; /* the standard deviation of the + Gaussian, in pixels */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, embossed image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rdd", + &handle_id, &radius, &sigma ) == 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 ) ; + + new_image = EmbossImage( handle->image, radius, sigma, + &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_enhance ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, enhanced image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ) ; + + new_image = EnhanceImage( handle->image, &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_gaussianblur ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double radius ; /* the radius of the Gaussian, in + pixels, not counting the center + pixel; using 0 will cause a + suitable radius to be selected + for you */ + double sigma ; /* the standard deviation of the + Gaussian, in pixels */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, Gaussian blurred image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rdd", + &handle_id, &radius, &sigma ) == 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 ) ; + + new_image = GaussianBlurImage( handle->image, radius, sigma, + &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_medianfilter ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double radius ; /* the radius of the pixel neighbor- + hood */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, median filtered image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rd", + &handle_id, &radius ) == 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 ) ; + + new_image = MedianFilterImage( handle->image, radius, + &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_motionblur ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double radius ; /* the radius of the Gaussian, in + pixels, not counter the center + pixel */ + double sigma ; /* the standard deviation of the + Gaussian, in pixels */ + double angle ; /* apply the effect along this angle */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, motion blurred image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rddd", + &handle_id, &radius, &sigma, &angle ) == 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 ) ; + + new_image = MotionBlurImage( handle->image, radius, sigma, + angle, &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_reducenoise ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double radius ; /* the radius of the pixel + neighborhood */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, noise reduced image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rd", + &handle_id, &radius ) == 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 ) ; + + new_image = ReduceNoiseImage( handle->image, radius, + &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_shade ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + long gray ; /* a value other than zero shades the + intensity of each pixel */ + double azimuth ; /* define light source direction */ + double elevation ; /* define light source direction */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, shaded image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rldd", + &handle_id, &gray, &azimuth, &elevation ) == 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 ) ; + + new_image = ShadeImage( handle->image, gray, azimuth, elevation, + &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_sharpen ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double radius ; /* the radius of the Gaussian, in + pixels, not counting the center + pixel */ + double sigma ; /* the standard deviation of the + Laplacian, in pixels */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, sharpened image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rdd", + &handle_id, &radius, &sigma ) == 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 ) ; + + new_image = SharpenImage( handle->image, radius, sigma, + &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_spread ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + long radius ; /* choose a random pixel in a neighbor- + hood of this extent */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new, spread image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rl", + &handle_id, &radius ) == 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 ) ; + + new_image = SpreadImage( handle->image, radius, &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_threshold ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double threshold ; /* define the threshold value */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rd", + &handle_id, &threshold ) == 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 ) ; + + ThresholdImage( handle->image, threshold ) ; + if ( _php_imagick_is_error( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_unsharpmask ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + double radius ; /* the radius of the Gaussian, in + pixels, not counting the center + pixel */ + double sigma ; /* the standard deviation of the + Gaussian, in pixels */ + double amount ; /* the percentage of the difference + between the original and the blur + blur image that is added back into + the original */ + double threshold ; /* the threshold in pixels needed to + apply the difference amount */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* new_image ; /* the new image */ + + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rdddd", + &handle_id, &radius, &sigma, &amount, &threshold ) + == 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 ) ; + + new_image = UnsharpMaskImage( handle->image, radius, sigma, amount, + threshold, &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + if ( new_image ) + { + DestroyImage( new_image ) ; + } + } + + DestroyImage( handle->image ) ; + handle->image = new_image ; + + RETURN_TRUE ; +} + +/*****************************************************************************/ + +/****************************************************************************** +} + +/*****************************************************************************/ + +/****************************************************************************** + * + * Image list manipulation. + * + */ + +PHP_FUNCTION( imagick_next ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + Image* next_image ; /* the next image in the list if it + exists */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ) ; + + next_image = GetNextImage( handle->image ) ; + if ( next_image == ( Image* )NULL ) + { + RETURN_FALSE ; + } + + handle->image = next_image ; + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_prev ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ) ; + + /***** + + ImageMagick did not have a previous image function built in + until 5.5.2. Since we support older versions, we'll just write + our own instead of relying on theirs. In the future, this code + should be replaced with the native previous function written into + ImageMagick > 5.5.2. + + *****/ + + if ( handle->image == ( Image* )NULL ) + { + RETURN_FALSE ; + } + + if ( handle->image->signature != MagickSignature ) + { + php_error( E_WARNING, "%s(): image signature does not match MagickSignature", get_active_function_name( TSRMLS_C ) ) ; + RETURN_FALSE ; + } + + if ( handle->image->previous == ( Image* )NULL ) + { + RETURN_FALSE ; + } + + handle->image = handle->image->previous ; + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_first ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ( !_php_imagick_first_image_in_list( handle ) ) + { + RETURN_FALSE ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_goto ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + long frame ; /* the frame to go to */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + int counter ; /* generic loop counter */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rl", + &handle_id, &frame ) == 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 ( frame < 0 ) + { + RETURN_FALSE ; + } + + if ( handle->image == ( Image* )NULL ) + { + RETURN_FALSE ; + } + + if ( handle->image->signature != MagickSignature ) + { + php_error( E_WARNING, "%s(): image signature does not match MagickSignature", get_active_function_name( TSRMLS_C ) ) ; + RETURN_FALSE ; + } + + if ( GetImageListSize( handle->image ) < frame ) + { + ThrowException( &handle->exception, WarningException, "image list does not contain that many frames in imagick_goto()", NULL ) ; + RETURN_FALSE ; + } + + /***** + + First, let's go back to the first image in the list. + + ****/ + + _php_imagick_first_image_in_list( handle ) ; + + for ( counter = 0 ; counter < frame ; counter++ ) + { + handle->image = handle->image->next ; + } + + RETURN_TRUE ; +} + +PHP_FUNCTION( imagick_getlistsize ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ) ; + + RETURN_LONG( GetImageListSize( handle->image ) ) ; +} + +PHP_FUNCTION( imagick_getlistindex ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ) ; + + RETURN_LONG( GetImageListIndex( handle->image ) ) ; +} + +PHP_FUNCTION( imagick_getimagefromlist ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + imagick_t* new_handle ; /* the new handle containing the + image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ) ; + + new_handle = _php_imagick_alloc_handle() ; + if ( !new_handle ) + { + RETURN_FALSE ; + } + + /***** + + The point of this function is to extract JUST the image we're + currently point at. So we'll only CloneImage() (not + CloneImageList()) and consider the image an orphan. + + *****/ + + new_handle->image = CloneImage( handle->image, 0, 0, 1, + &new_handle->exception ) ; + + /***** + + _php_imagick_alloc_handle() already created a NULL image_info + structure. We want to safely clean that up before assigning the + new one. + + *****/ + + if ( new_handle->image_info ) + { + DestroyImageInfo( new_handle->image_info ) ; + } + new_handle->image_info = CloneImageInfo( handle->image_info ) ; + + new_handle->id = zend_list_insert( new_handle, le_handle ) ; + RETURN_RESOURCE( new_handle->id ) ; +} + +/*****************************************************************************/ + +/****************************************************************************** + * + * Clean up. + * + */ + +PHP_FUNCTION( imagick_destroyhandle ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle_id ) == 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 ; + } + + /***** + + zend_list_delete() will take care of the memory allocated for + the handle. + + *****/ + + zend_list_delete( handle->id ) ; + + RETURN_TRUE ; +} + +/*****************************************************************************/ + +/****************************************************************************** + * + * Internal functions. + * + */ + +static void _php_imagick_init( void ) +{ + if ( IMAGICK_G( imagick_was_init ) == 1 ) + { + return ; + } + + InitializeMagick( NULL ) ; + + /***** + + If you want to see the ImageMagick engine exception messages + output to stderr, change IMAGICK_TURN_OFF_ERRORS_TO_STDERR to + 0 in ./imagick.h. + + *****/ + + if ( IMAGICK_TURN_OFF_ERRORS_TO_STDERR == 1 ) + { + SetErrorHandler( _php_imagick_error_handler ) ; + } + + IMAGICK_G( imagick_was_init ) = 1 ; +} + +static imagick_t* _php_imagick_alloc_handle( void ) +{ + imagick_t* handle ; /* the new handle to create */ + + handle = ( imagick_t* )emalloc( sizeof( imagick_t ) ) ; + if ( !handle ) + { + php_error( E_ERROR, "%s(): could not allocate imagick_t structure for new image handle", get_active_function_name( TSRMLS_C ) ) ; + return ( imagick_t* )NULL ; + } + + /***** + + Set all structure members to default values. POINTERS SHOULD BE + SET TO NULL and _php_imagick_clean_up_handle() should be modified + to clean up any additional members added. + + *****/ + + handle->id = -1 ; + handle->image = NULL ; + handle->image_info = CloneImageInfo( ( ImageInfo* )NULL ) ; + GetExceptionInfo( &handle->exception ) ; + handle->draw_info = NULL ; + handle->draw_context = NULL ; + + return handle ; +} + +static void _php_imagick_clean_up_handle( imagick_t* handle ) +{ + if ( !handle ) + { + return ; + } + + if ( handle->image ) + { + DestroyImageList( handle->image ) ; + } + + if ( handle->image_info ) + { + DestroyImageInfo( handle->image_info ) ; + } + + DestroyExceptionInfo( &handle->exception ) ; + + if ( handle->draw_info ) + { + DestroyDrawInfo( handle->draw_info ) ; + } + + if ( handle->draw_context ) + { + DrawDestroyContext( handle->draw_context ) ; + } + + efree( handle ) ; +} + +static void _php_imagick_free_handle_list( zend_rsrc_list_entry* rsrc TSRMLS_DC ) +{ + imagick_t* handle ; /* the handle to free */ + + handle = ( imagick_t* )rsrc->ptr ; + if ( handle ) + { + _php_imagick_clean_up_handle( handle ) ; + } +} + +static imagick_t* _php_imagick_get_handle_struct_from_list( zval** handle_id TSRMLS_DC ) +{ + imagick_t* handle ; /* the imagick_t handle - used to + perform any ops. on the image */ + + handle = ( imagick_t* )zend_fetch_resource( handle_id TSRMLS_CC, -1, + "imagemagick handle", NULL, 1, le_handle ) ; + if ( !handle ) + { + return ( imagick_t* )NULL ; + } + + return handle ; +} + +void _php_imagick_error_handler( const ExceptionType exception, const char* a, + const char* b ) +{ + /***** + + We don't want anything being displayed to stderr. So we'll + do nothing with errors assuming they will be properly assigned + to an ExceptionInfo structure. + + *****/ +} + +static void _php_imagick_clear_errors( imagick_t* handle ) +{ + if ( !handle ) + { + return ; + } + + handle->exception.severity = UndefinedException ; + handle->image->exception.severity = UndefinedException ; + + /***** + + I don't actually free the memory allocated for the reason and + description because I don't know how ImageMagick is going to use + it. ImageMagick might declare the reason and description to + a fixed length and then just strncpy() messages into the + memory. So to be safe, we'll just leave the memory intact. + + *****/ +} + +static int _php_imagick_is_error( const imagick_t* handle ) +{ + if ( handle->exception.severity != UndefinedException || + handle->image->exception.severity != UndefinedException ) + { + return 1 ; + } + + return 0 ; +} + +/* + * This function is here to facilitate supporting backwards compatible + * functions, namely imagick_read(). If the backwards compatibility + * functions are removed, the statements in this function can be moved + * into image_readimage() directly. +*/ +static imagick_t* _php_imagick_readimage( const char* file_name ) +{ + imagick_t* handle ; /* the new image handle */ + + if ( !file_name ) + { + return NULL ; + } + + if ( IMAGICK_G( imagick_was_init ) == 0 ) + { + /***** + + Initialize the ImageMagick engine. + + *****/ + + _php_imagick_init() ; + } + + handle = _php_imagick_alloc_handle() ; + if ( !handle ) + { + return NULL ; + } + handle->id = zend_list_insert( handle, le_handle ) ; + + strncpy( handle->image_info->filename, file_name, MaxTextExtent - 1 ) ; + + handle->image = ReadImage( handle->image_info, &handle->exception ) ; + if ( _php_imagick_is_error( handle ) ) + { + return handle ; + } + + if ( !handle->image ) + { + ThrowException( &handle->exception, FatalErrorException, "after ReadImage(), image is empty in _php_imagick_readimage()", NULL ) ; + return handle ; + } + + return handle ; +} + +static int _php_imagick_first_image_in_list( imagick_t* handle ) +{ + if ( !handle ) + { + return 0 ; + } + + if ( handle->image == ( Image* )NULL ) + { + return 0 ; + } + + if ( handle->image->signature != MagickSignature ) + { + php_error( E_WARNING, "%s(): image signature does not match MagickSignature", get_active_function_name( TSRMLS_C ) ) ; + return 0 ; + } + + while( handle->image->previous != ( Image* )NULL ) + { + handle->image = handle->image->previous ; + } + + return 1 ; +} + +/*****************************************************************************/ + +/****************************************************************************** + * + * Backward compatibility with old imagick extension. + * + */ + +PHP_FUNCTION( imagick_read ) +{ + zval* handle_id ; /* this is not used here and is + maintained for backward + compatibility only */ + char* file_name ; /* the file name to use to retrieve + the image */ + int file_name_len ; /* string length of the file name */ + imagick_t* handle ; /* the handle for this image */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "rs", + &handle_id, &file_name, &file_name_len ) == FAILURE ) + { + return ; + } + + handle = _php_imagick_readimage( file_name ) ; + RETURN_RESOURCE( handle->id ) ; +} + +PHP_FUNCTION( imagick_free ) +{ + zval* handle_id ; /* the handle identifier coming from + the PHP environment */ + imagick_t* handle ; /* the actual imagick_t struct for the + handle */ + + if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "r", + &handle ) == 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 ; + } + + /***** + + zend_list_delete() will take care of the memory allocated for + the handle. + + *****/ + + zend_list_delete( handle->id ) ; + + RETURN_TRUE ; +} + +/*****************************************************************************/ + +/****************************************************************************** + * + * Deprecated functions from old imagick extension. + * + */ + +PHP_FUNCTION( imagick_add_resource ) +{ + IMAGICK_DEPCREATED() ; + RETURN_FALSE ; +} + +PHP_FUNCTION( imagick_list_magickinfo ) +{ + IMAGICK_DEPCREATED() ; + RETURN_FALSE ; +} + +PHP_FUNCTION( imagick_new ) +{ + IMAGICK_DEPCREATED() ; + RETURN_FALSE ; +} + +PHP_FUNCTION( imagick_init ) +{ + IMAGICK_DEPCREATED() ; + RETURN_FALSE ; +} + +PHP_FUNCTION( imagick_copy_sample ) +{ + IMAGICK_DEPCREATED() ; + RETURN_FALSE ; +} + +PHP_FUNCTION( imagick_copy_resize ) +{ + IMAGICK_DEPCREATED() ; + RETURN_FALSE ; +} + +PHP_FUNCTION( imagick_copy_crop ) +{ + IMAGICK_DEPCREATED() ; + RETURN_FALSE ; +} + +PHP_FUNCTION( imagick_copy_shear ) +{ + IMAGICK_DEPCREATED() ; + RETURN_FALSE ; +} + +PHP_FUNCTION( imagick_copy_rotate ) +{ + IMAGICK_DEPCREATED() ; + RETURN_FALSE ; +} + +PHP_FUNCTION( imagick_copy_morph ) +{ + IMAGICK_DEPCREATED() ; + RETURN_FALSE ; +} + +PHP_FUNCTION( imagick_dump ) +{ + IMAGICK_DEPCREATED() ; + RETURN_FALSE ; +} + +/*****************************************************************************/ Index: pear/PECL/imagick/package.xml diff -u /dev/null pear/PECL/imagick/package.xml:1.10 --- /dev/null Mon Dec 2 16:25:23 2002 +++ pear/PECL/imagick/package.xml Mon Dec 2 16:25:21 2002 @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="ISO-8859-1" ?> +<!-- do not use the "Type" attribute here, that one is only for + generated package.xml files --> +<package> + <name>imagick</name> + <summary>Provides a wrapper to the Image Magick Library. </summary> + <description>It's a native php-extension. + See http://pear.php.net/manual/en/pecl.imagick.php for installation and usage notes</description> + <maintainer> + <user>chregu</user> + <name>Christian Stocker</name> + <email>chregu@php.net</email> + </maintainer> + <maintainer> + <user>mcmontero</user> + <name>Michael C. Montero</name> + <email>mmontero@mail.communityconnect.com</email> + </maintainer> + <license>PHP License</license> + <release> + <version>0.9a</version> + <date>2002-12-02</date> + <notes> + - functions added: + imagick_next() + imagick_prev() + imagick_first() + imagick_goto() + imagick_getlistsize() + imagick_getlistindex() + imagick_getimagefromlist() + imagick_blob2image() + imagick_reducenoise() + imagick_shade() + imagick_sharpen() + imagick_spread() + imagick_threshold() + imagick_unsharpmask() + - cut over deprecation reporting to a more standized and easier + to use method + - cut over all php_error calls to standard method + - added Christian's code to info function for displaying a list of + supported image formats + - rewrote all code to use proper parameter parsing function + - fixed minor issue with a number of example files; was nothing + critical + </notes> + <state>beta</state> + </release> + <release> + <version>0.5a</version> + <date>2002-11-25</date> + <notes> + - functions added: + imagick_getcanvas() + imagick_blur() + imagick_despeckle() + imagick_edge() + imagick_emboss() + imagick_enhance() + imagick_gaussianblur() + imagick_medianfilter() + imagick_motionblur() + - one major change - renamed everything to imagick*; I've joined my + efforts with Christian Stocker who had a previously written but + smaller extension + - magick_getcanvas() allows you to create a blank image to draw on + - changed comment header in imagick.h to match the one in imagick.c + - added Christian Stocker to credits + - moved over to Christian Stocker's config.m4, removed the need + for gen_configm4 + - rewrote INSTALL to reflect new config.m4 + - slight modifications to config.m4 to get it to work properly + - added package.xml + - removed ChangeLog, everything is now in package.xml + - removed imagick_free_reason() and imagick_free_description() since + they are no longer necessary + - preceded all internal functions with _php_ + - created imagick_read() for backward compatibility with old extension + - created imagick_write() for backward compatibility with old extension + </notes> + <state>beta</state> + </release> + <release> + <version>0.4a</version> + <date>2002-11-22</date> + <notes> + - functions added: + magick_writeimages() + magick_destroyhandle() + magick_image2blob() + magick_drawarc() + magick_drawcircle() + magick_drawpoint() + magick_border() + magick_frame() + magick_raise() + magick_getwidth() + magick_getheight() + magick_getmimetype() + magick_setfillcolor() + magick_setfontface() + magick_charcoal() + magick_implode() + magick_oilpaint() + magick_solarize() + magick_swirl() + magick_wave() + - more preparation for image lists + - fixed incorrect comments in some examples + - fixed incorrect calls to magick_failedreason() and + magick_faileddescription() in most examples + - a number of examples weren't exiting properly on errors, + that's been fixed + - phpinfo() now displays available font family and font names + - coolest function so far: magick_oilpaint(). The output is + awesome! + - added MaxRGB to phpinfo() section + </notes> + <state>alpha</state> + </release> + <release> + <version>0.2a</version> + <date>2002-11-21</date> + <notes> + - functions added: + magick_rotate() + magick_shear() + magick_contrast() + magick_equalize() + magick_gamma() + magick_level() + magick_modulate() + magick_negate() + magick_normalize() + magick_drawellipse() + - slight changes to output of gen_configm4 + - fixed comments in all examples after the initial magick_readimage(), + they were wrong + - fixed all examples so they exit properly on errors + - fixed all examples so they work as either standalone script or web + page; they do better output as well + - fixed output of magick info. when calling phpinfo() + - more commenting + - significantly better error handling + </notes> + <state>alpha</state> + </release> + <release> + <version>0.1.2</version> + <date>2002-09-01</date> + <notes> + - Added imagick_border(). (pierre-alain joye) + - Fixed return of annotate and rotate (true on success). (pierre-alain joye) + </notes> + <state>alpha</state> + </release> + <configureoptions> + <configureoption name="with-imagick" default="autodetect" prompt="ImageMagick library install dir?"/> + </configureoptions> + + <filelist> + <dir role="source" name="/" > + <file role="doc">CREDITS</file> + <file role="doc">INSTALL</file> + <file role="ext">Makefile.in</file> + <file role="ext">config.m4</file> + <file role="ext">imagick.c</file> + <file role="ext">imagick.h</file> + <file role="ext">package.xml</file> + <file role="php">imagick.php</file> + <file role="ext">php_imagick.h</file> + </dir> + </filelist> + <changelog> + <release> + <version>0.1.1</version> + <date>2002-05-29</date> + <notes> + - Make it compatible with ImageMagick 5.4.5 (and this is also the needed version now) + - adjust package.xml to the new "pear build" command + </notes> + <state>alpha</state> + </release> + + <release> + + <version>0.1</version> + <date>2002-01-15</date> + <notes> + - imagick_sample(), imagick_resize(), imagick_crop(), imagick_shear(), imagick_rotate(), imagick_morph() are depraceted and replaced by the corresponding imagick_copy_* function, which return a new handle. The depracated functions will be removed in the next version. + - Cosmetic changes to phpinfo() + - bugfix for loading images without segfaults + - Fixed some critical resource allocation errors + - Make it compatible with ImageMagick 5.4.5 + </notes> + <state>alpha</state> + </release> + </changelog> + + +</package> Index: pear/PECL/imagick/php_imagick.h diff -u /dev/null pear/PECL/imagick/php_imagick.h:1.7 --- /dev/null Mon Dec 2 16:25:23 2002 +++ pear/PECL/imagick/php_imagick.h Mon Dec 2 16:25:21 2002 @@ -0,0 +1,241 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 4 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2002 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Michael Montero (mmontero@mail.communityconnect.com) | + | Christian Stocker (chregu@bitflux.ch) | + +----------------------------------------------------------------------+ + + $Id: php_imagick.h,v 1.7 2002/12/02 21:25:21 chregu Exp $ +*/ + +#ifndef PHP_IMAGICK_H +#define PHP_IMAGICK_H + + extern zend_module_entry imagick_module_entry ; + #define phpext_imagick_ptr &imagick_module_entry + + #ifdef PHP_WIN32 + #define PHP_IMAGICK_API __declspec( dllexport ) + #else + #define PHP_IMAGICK_API + #endif + + #ifdef ZTS + #include "TSRM.h" + #endif + + ZEND_BEGIN_MODULE_GLOBALS( imagick ) + int imagick_was_init ; + ZEND_END_MODULE_GLOBALS( imagick ) + + #ifdef ZTS + # define IMAGICK_G( v ) TSRMG( imagick_globals_id, zend_imagick_globals *, v ) + #else + # define IMAGICK_G( v ) ( imagick_globals.v ) + #endif + + PHP_MINIT_FUNCTION( imagick ) ; + PHP_RINIT_FUNCTION( imagick ) ; + PHP_RSHUTDOWN_FUNCTION( imagick ) ; + PHP_MINFO_FUNCTION( imagick ) ; + + /***** + + Constitue an image. + + *****/ + + PHP_FUNCTION( imagick_readimage ) ; + PHP_FUNCTION( imagick_writeimage ) ; + PHP_FUNCTION( imagick_writeimages ) ; + PHP_FUNCTION( imagick_clonehandle) ; + PHP_FUNCTION( imagick_image2blob ) ; + PHP_FUNCTION( imagick_blob2image ) ; + PHP_FUNCTION( imagick_getcanvas ) ; + + /***** + + Error handling. + + *****/ + + PHP_FUNCTION( imagick_iserror ) ; + PHP_FUNCTION( imagick_failedreason ) ; + PHP_FUNCTION( imagick_faileddescription ) ; + + /***** + + Getting information about an image. + + *****/ + + PHP_FUNCTION( imagick_getwidth ) ; + PHP_FUNCTION( imagick_getheight ) ; + PHP_FUNCTION( imagick_getmimetype ) ; + + /***** + + Convert an image. + + *****/ + + PHP_FUNCTION( imagick_convert ) ; + + /***** + + Resize an image. + + *****/ + + PHP_FUNCTION( imagick_resize ) ; + PHP_FUNCTION( imagick_magnify ) ; + PHP_FUNCTION( imagick_minify ) ; + PHP_FUNCTION( imagick_scale ) ; + PHP_FUNCTION( imagick_sample ) ; + + /***** + + Font settings. + + *****/ + + PHP_FUNCTION( imagick_setfontsize ) ; + PHP_FUNCTION( imagick_setfontstyle ) ; + PHP_FUNCTION( imagick_setfontface ) ; + + /***** + + Draw on an image. + + *****/ + + PHP_FUNCTION( imagick_begindraw ) ; + PHP_FUNCTION( imagick_drawannotation ) ; + PHP_FUNCTION( imagick_drawrectangle ) ; + PHP_FUNCTION( imagick_drawellipse ) ; + PHP_FUNCTION( imagick_drawarc ) ; + PHP_FUNCTION( imagick_drawcircle ) ; + PHP_FUNCTION( imagick_drawline ) ; + PHP_FUNCTION( imagick_drawpoint ) ; + PHP_FUNCTION( imagick_setfillcolor ) ; + + /***** + + Enhance an image. + + *****/ + + PHP_FUNCTION( imagick_rotate ) ; + PHP_FUNCTION( imagick_shear ) ; + PHP_FUNCTION( imagick_contrast ) ; + PHP_FUNCTION( imagick_equalize ) ; + PHP_FUNCTION( imagick_gamma ) ; + PHP_FUNCTION( imagick_level ) ; + PHP_FUNCTION( imagick_modulate ) ; + PHP_FUNCTION( imagick_negate ) ; + PHP_FUNCTION( imagick_normalize ) ; + + /***** + + Decorate an image. + + *****/ + + PHP_FUNCTION( imagick_border ) ; + PHP_FUNCTION( imagick_frame ) ; + PHP_FUNCTION( imagick_raise ) ; + + /***** + + Special effects. + + *****/ + + PHP_FUNCTION( imagick_charcoal ) ; + PHP_FUNCTION( imagick_implode ) ; + PHP_FUNCTION( imagick_oilpaint ) ; + PHP_FUNCTION( imagick_solarize ) ; + PHP_FUNCTION( imagick_swirl ) ; + PHP_FUNCTION( imagick_wave ) ; + + /***** + + Image effects. + + *****/ + + PHP_FUNCTION( imagick_blur ) ; + PHP_FUNCTION( imagick_despeckle ) ; + PHP_FUNCTION( imagick_edge ) ; + PHP_FUNCTION( imagick_emboss ) ; + PHP_FUNCTION( imagick_enhance ) ; + PHP_FUNCTION( imagick_gaussianblur ) ; + PHP_FUNCTION( imagick_medianfilter ) ; + PHP_FUNCTION( imagick_motionblur ) ; + PHP_FUNCTION( imagick_reducenoise ) ; + PHP_FUNCTION( imagick_shade ) ; + PHP_FUNCTION( imagick_sharpen ) ; + PHP_FUNCTION( imagick_spread ) ; + PHP_FUNCTION( imagick_threshold ) ; + PHP_FUNCTION( imagick_unsharpmask ) ; + + /***** + + Image list manipulation. + + *****/ + + PHP_FUNCTION( imagick_next ) ; + PHP_FUNCTION( imagick_prev ) ; + PHP_FUNCTION( imagick_first ) ; + PHP_FUNCTION( imagick_goto ) ; + PHP_FUNCTION( imagick_getlistsize ) ; + PHP_FUNCTION( imagick_getlistindex ) ; + PHP_FUNCTION( imagick_getimagefromlist ) ; + + /***** + + Clean up. + + *****/ + + PHP_FUNCTION( imagick_destroyhandle ) ; + + /***** + + Backward compatibility with old imagick extension. + + *****/ + + PHP_FUNCTION( imagick_read ) ; /* => imagick_readimage() */ + PHP_FUNCTION( imagick_free ) ; /* => imagick_destroyhandle() */ + /***** + + Deprecated functions from old imagick extension. + + *****/ + + PHP_FUNCTION( imagick_add_resource ) ; + PHP_FUNCTION( imagick_list_magickinfo ) ; + PHP_FUNCTION( imagick_new ) ; + PHP_FUNCTION( imagick_init ) ; + PHP_FUNCTION( imagick_copy_sample ) ; + PHP_FUNCTION( imagick_copy_resize ) ; + PHP_FUNCTION( imagick_copy_crop ) ; + PHP_FUNCTION( imagick_copy_shear ) ; + PHP_FUNCTION( imagick_copy_rotate ) ; + PHP_FUNCTION( imagick_copy_morph ) ; + PHP_FUNCTION( imagick_dump ) ; + +#endif /* PHP_IMAGICK_H */ Index: pear/PECL/imagick/CREDITS diff -u pear/PECL/imagick/CREDITS:1.2 pear/PECL/imagick/CREDITS:1.3 --- pear/PECL/imagick/CREDITS:1.2 Tue Jan 15 10:13:34 2002 +++ pear/PECL/imagick/CREDITS Mon Dec 2 16:25:21 2002 @@ -1,3 +1,2 @@ imagick - ImageMagick Extension -Christian Stocker, Andrei Nigmatulin - +Michael Montero, Christian Stocker, Daniel Cowgill, Bob Friesenhahn Index: pear/PECL/imagick/imagick.h +++ pear/PECL/imagick/imagick.h /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2002 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Michael Montero (mmontero@mail.communityconnect.com) | | Christian Stocker (chregu@bitflux.ch) | +----------------------------------------------------------------------+ $Id: imagick.h,v 1.1 2002/12/02 21:25:21 chregu Exp $ */ #ifndef IMAGICKH #define IMAGICKH #include <magick/api.h> #define IMAGICK_VERSION "0.9a" #define IMAGICK_TURN_OFF_ERRORS_TO_STDERR 1 #define IMAGICK_DEPCREATED() php_error( E_WARNING, "%s(): this function is deprecated and will be removed soon", get_active_function_name( TSRMLS_C ) ) ; /***** This structure is used for all image processing. Anyone calling an imagick function in PHP will be given and will pass around a handle. This handle is used to identify a structure of the type defined below. *****/ typedef struct { int id ; /* used to pass around within PHP code */ Image* image ; /* ImageMagick Image structure for the presently selected image */ ImageInfo* image_info ; /* ImageMagick ImageInfo structure describing the current image */ ExceptionInfo exception ; /* stores any exceptions */ DrawInfo* draw_info ; /* ImageMagick DrawInfo structure to use when allocating a DrawContext */ DrawContext draw_context ; /* ImageMagick DrawContext structure for vector based drawing */ } imagick_t ; /***** Function prototypes *****/ static void _php_imagick_init( void ) ; static void _php_imagick_free_handle_list( zend_rsrc_list_entry* rsrc TSRMLS_DC ) ; static imagick_t* _php_imagick_get_handle_struct_from_list( zval** handle_id TSRMLS_DC ) ; static void _php_imagick_clean_up_handle( imagick_t* ) ; static imagick_t* _php_imagick_alloc_handle( void ) ; static void _php_imagick_error_handler( const ExceptionType, const char*, const char* ) ; static void _php_imagick_clear_errors( imagick_t* ) ; static int _php_imagick_is_error( const imagick_t* ) ; static imagick_t* _php_imagick_readimage( const char* ) ; static int _php_imagick_first_image_in_list( imagick_t* ) ; #endif /* IMAGICKH */ Index: pear/PECL/imagick/examples/animatedgif2jpgs.php +++ pear/PECL/imagick/examples/animatedgif2jpgs.php <? $handle = imagick_readimage( "./animated.gif" ) ; 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_writeimages( $handle, "./new_image.jpg" ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_writeimages() failed<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/annotate.php +++ pear/PECL/imagick/examples/annotate.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 ; } imagick_begindraw( $handle ) ; if ( !imagick_setfillcolor( $handle, "#ff0000" ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_setfillcolor() failed<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } if ( !imagick_setfontsize( $handle, 16 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_setfontsize() failed<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } if ( !imagick_setfontstyle( $handle, IMAGICK_FONTSTYLE_ITALIC ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_setfontstyle() failed<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } if ( !imagick_drawannotation( $handle, 325, 100, "Ahhhh, Cozumel!" ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_drawannotation() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/arc.php +++ pear/PECL/imagick/examples/arc.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 ; } imagick_begindraw( $handle ) ; if ( !imagick_drawarc( $handle, 50, 50, 187.2, 237.6, 30, 180 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_drawarc() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/blob2image.php +++ pear/PECL/imagick/examples/blob2image.php <? $fp = fopen( "./image.jpg", "r" ) ; if ( !$fp ) { print "Cannot open image.jpg!<BR>\n" ; exit ; } $blob = fread( $fp, filesize( "./image.jpg" ) ) ; fclose( $fp ) ; $handle = imagick_blob2image( $blob ) ; if ( imagick_iserror( $handle ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_blob2image() failed<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } imagick_scale( $handle, 800, 800 ) ; 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/blur.php +++ pear/PECL/imagick/examples/blur.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_blur( $handle, 10, 10 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_blur() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/border.php +++ pear/PECL/imagick/examples/border.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_border( $handle, 0, 0, 10, 10 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_border() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/charcoal.php +++ pear/PECL/imagick/examples/charcoal.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_charcoal( $handle, 1, 1 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_charcoal() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/circle.php +++ pear/PECL/imagick/examples/circle.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 ; } imagick_begindraw( $handle ) ; if ( !imagick_drawcircle( $handle, 50, 50, 80, 80 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_drawcircle() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/clone_handle.php +++ pear/PECL/imagick/examples/clone_handle.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 ; } $cloned_handle = imagick_clonehandle( $handle ) ; imagick_scale( $cloned_handle, 640, 480 ) ; if ( !imagick_writeimage( $cloned_handle, "./new_image.tif" ) ) { $reason = imagick_failedreason( $cloned_handle ) ; $description = imagick_faileddescription( $cloned_handle ) ; print "imagick_writeimage() failed<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/contrast.php +++ pear/PECL/imagick/examples/contrast.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 ; } imagick_contrast( $handle, 0 ) ; 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/convert1.php +++ pear/PECL/imagick/examples/convert1.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_writeimage( $handle, "./new_image.gif" ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_writeimage() failed<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/convert2.php +++ pear/PECL/imagick/examples/convert2.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 ; } imagick_convert( $handle, "GIF" ) ; // // I intentionally left the .gif extension off the file name to // demonstrate a second way to convert images. You might use // this method when reading an image from a file, converting it // and then immediately displaying it to the user. // if ( !imagick_writeimage( $handle, "./new_image" ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_writeimage() failed<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/convert_and_resize.php +++ pear/PECL/imagick/examples/convert_and_resize.php <? $handle = imagick_readimage( "./some_image_that_doesnt_exist.jpg" ) ; if ( imagick_iserror( $handle ) ) { // // This should fail! Notice the image name is spelled // incorrectly. This is to demonstrate error reporting. // $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } $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 ; } imagick_convert( $handle, "GIF" ) ; if ( !imagick_resize( $handle, 800, 600, IMAGICK_FILTER_QUADRATIC, 0 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_resize() failed<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } if ( !imagick_magnify( $handle ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_magnify() failed<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } if ( !imagick_minify( $handle ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_minify() failed<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } if ( !imagick_sample( $handle, 300, 300 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_sample() failed<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } if ( !imagick_writeimage( $handle, "./new_image.gif" ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_writeimage() failed<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/despeckle.php +++ pear/PECL/imagick/examples/despeckle.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_despeckle( $handle, 10, 10 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_despeckle() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/destroyhandle.php +++ pear/PECL/imagick/examples/destroyhandle.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 ; } imagick_destroyhandle( $handle ) ; // // This will fail. // 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/edge.php +++ pear/PECL/imagick/examples/edge.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_edge( $handle, 10 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_edge() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/ellipse.php +++ pear/PECL/imagick/examples/ellipse.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 ; } imagick_begindraw( $handle ) ; if ( !imagick_drawellipse( $handle, 50, 50, 72, 129.6, 0, 360 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_drawellipse() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/emboss.php +++ pear/PECL/imagick/examples/emboss.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_emboss( $handle, 5, 5 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_emboss() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/enhance.php +++ pear/PECL/imagick/examples/enhance.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_enhance( $handle ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_enhance() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/equalize.php +++ pear/PECL/imagick/examples/equalize.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 ; } imagick_equalize( $handle ) ; 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/first.php +++ pear/PECL/imagick/examples/first.php <? $handle = imagick_readimage( "./animated.gif" ) ; if ( imagick_iserror( $handle ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "handle2 failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } // // Move 2 frames in, then come back to the first frame. // imagick_next( $handle ) ; imagick_next( $handle ) ; imagick_first( $handle ) ; // // Extract just the current image from the list. // $new_handle = imagick_getimagefromlist( $handle ) ; header( "Content-type: " . imagick_getmimetype( $new_handle ) ) ; print imagick_image2blob( $new_handle ) ; ?> Index: pear/PECL/imagick/examples/gamma.php +++ pear/PECL/imagick/examples/gamma.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 ; } imagick_gamma( $handle, 2.3 ) ; 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/gaussianblur.php +++ pear/PECL/imagick/examples/gaussianblur.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_gaussianblur( $handle, 10, 10 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_gaussianblur() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/getcanvas.php +++ pear/PECL/imagick/examples/getcanvas.php <? $handle = imagick_getcanvas( "#ff0000", 200, 200 ) ; 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_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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/getlistindex.php +++ pear/PECL/imagick/examples/getlistindex.php <? $handle = imagick_readimage( "./animated.gif" ) ; if ( imagick_iserror( $handle ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } imagick_next( $handle ) ; imagick_next( $handle ) ; imagick_next( $handle ) ; print "You are frame #" . imagick_getlistindex( $handle ) . "<BR>\n" ; ?> Index: pear/PECL/imagick/examples/getlistsize.php +++ pear/PECL/imagick/examples/getlistsize.php <? $handle = imagick_readimage( "./animated.gif" ) ; if ( imagick_iserror( $handle ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "handle failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } print "Number of frames in image: " . imagick_getlistsize( $handle ) . "<BR>\n" ; ?> Index: pear/PECL/imagick/examples/getmimetype.php +++ pear/PECL/imagick/examples/getmimetype.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 ; } print imagick_getmimetype( $handle ) . "<BR>\n" ; ?> Index: pear/PECL/imagick/examples/goto.php +++ pear/PECL/imagick/examples/goto.php <? $handle = imagick_readimage( "./animated.gif" ) ; if ( imagick_iserror( $handle ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "handle2 failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } imagick_next( $handle ) ; imagick_next( $handle ) ; imagick_next( $handle ) ; imagick_next( $handle ) ; imagick_goto( $handle, 0 ) ; // // Extract just the current image from the list. // $new_handle = imagick_getimagefromlist( $handle ) ; header( "Content-type: " . imagick_getmimetype( $new_handle ) ) ; print imagick_image2blob( $new_handle ) ; ?> Index: pear/PECL/imagick/examples/image2blob.php +++ pear/PECL/imagick/examples/image2blob.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 ( !( $image_data = imagick_image2blob( $handle ) ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_image2blob() failed<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } header( "Content-type: " . imagick_getmimetype( $handle ) ) ; print $image_data ; ?> Index: pear/PECL/imagick/examples/implode.php +++ pear/PECL/imagick/examples/implode.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_implode( $handle, 1 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_implode() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/level.php +++ pear/PECL/imagick/examples/level.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 ; } imagick_level( $handle, 0 ) ; 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/line.php +++ pear/PECL/imagick/examples/line.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 ; } imagick_begindraw( $handle ) ; if ( !imagick_drawline( $handle, 50, 50, 50, 180 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_drawline() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/list1.php +++ pear/PECL/imagick/examples/list1.php <? $handle = imagick_readimage( "./animated.gif" ) ; if ( imagick_iserror( $handle ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "handle2 failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } $new_handle = imagick_clonehandle( $handle ) ; imagick_next( $new_handle ) ; imagick_next( $new_handle ) ; imagick_prev( $new_handle ) ; imagick_prev( $new_handle ) ; header( "Content-type: " . imagick_getmimetype( $new_handle ) ) ; print imagick_image2blob( $new_handle ) ; ?> Index: pear/PECL/imagick/examples/list2.php +++ pear/PECL/imagick/examples/list2.php <? $handle = imagick_readimage( "./animated.gif" ) ; if ( imagick_iserror( $handle ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "handle2 failed!<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } // // Extract just the current image from the list and convert it to // a JPEG. // $new_handle = imagick_getimagefromlist( $handle ) ; imagick_convert( $new_handle, "JPEG" ) ; header( "Content-type: " . imagick_getmimetype( $new_handle ) ) ; print imagick_image2blob( $new_handle ) ; ?> Index: pear/PECL/imagick/examples/medianfilter.php +++ pear/PECL/imagick/examples/medianfilter.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 ; } // // Note, this operation is slow and expensive. // if ( !imagick_medianfilter( $handle, 10 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_medianfilter() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/modulate.php +++ pear/PECL/imagick/examples/modulate.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 ; } imagick_modulate( $handle, 90 ) ; 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/motionblur.php +++ pear/PECL/imagick/examples/motionblur.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_motionblur( $handle, 2, 10, 90 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_motionblur() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/negate.php +++ pear/PECL/imagick/examples/negate.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 ; } imagick_negate( $handle, 0 ) ; // // or, imagick_negate( $handle, 1 ). 1 and 0 are the only valid // values for the second parameter. 1 means that only the gray scale // within the image should be negated. // 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/normalize.php +++ pear/PECL/imagick/examples/normalize.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 ; } imagick_normalize( $handle ) ; 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/oilpaint.php +++ pear/PECL/imagick/examples/oilpaint.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 ; } // // Note, this operation is SLOW and EXPENSIVE! // if ( !imagick_oilpaint( $handle, 3 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_oilpaint() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/point.php +++ pear/PECL/imagick/examples/point.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 ; } imagick_begindraw( $handle ) ; if ( !imagick_drawpoint( $handle, 300, 50 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_drawpoint() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/raise.php +++ pear/PECL/imagick/examples/raise.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 ; } // // The last parameter determines if the image should looked raised // or lowered. A non-zero value will raise the image, 0 will // lower it. // if ( !imagick_raise( $handle, 0, 0, 100, 100, 0 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_raise() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/rectangle.php +++ pear/PECL/imagick/examples/rectangle.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 ; } imagick_begindraw( $handle ) ; imagick_drawrectangle( $handle, 325, 50, 400, 350 ) ; 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/reducenoise.php +++ pear/PECL/imagick/examples/reducenoise.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 ; } // // Note, this can be a slow and expensive operation. // if ( !imagick_reducenoise( $handle, 1 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_reducenoise() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/rotate.php +++ pear/PECL/imagick/examples/rotate.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_rotate( $handle, -90 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_rotate() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/setfillcolor.php +++ pear/PECL/imagick/examples/setfillcolor.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 ; } imagick_begindraw( $handle ) ; if ( !imagick_setfillcolor( $handle, "FFFF00" ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_setfillcolor() failed<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } imagick_drawrectangle( $handle, 325, 50, 400, 350 ) ; 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/setfontface.php +++ pear/PECL/imagick/examples/setfontface.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 ; } imagick_begindraw( $handle ) ; // // For available fonts, see the Name value in phpinfo() under the // imagick section. // if ( !imagick_setfontface( $handle, "Palatino-Bold" ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_setfontface() failed<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } if ( !imagick_setfillcolor( $handle, "#990000" ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_setfontcolor() failed<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } if ( !imagick_setfontsize( $handle, 16 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_setfontsize() failed<BR>\nReason: $reason<BR>\nDescription: $description<BR>\n" ; exit ; } if ( !imagick_drawannotation( $handle, 325, 100, "Ahhhh, Cozumel!" ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_drawannotation() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/shade.php +++ pear/PECL/imagick/examples/shade.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_shade( $handle, 1, 85, 25 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_shade() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/sharpen.php +++ pear/PECL/imagick/examples/sharpen.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_sharpen( $handle, 10, 5 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_sharpen() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/shear.php +++ pear/PECL/imagick/examples/shear.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_shear( $handle, 10, 10 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_shear() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/solarize.php +++ pear/PECL/imagick/examples/solarize.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 ; } // // 2nd parameter is between 0 and MaxRGB. See phpinfo() for MaxRGB // value. // if ( !imagick_solarize( $handle, 10 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_solarize() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/spread.php +++ pear/PECL/imagick/examples/spread.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_spread( $handle, 5 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_spread() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/swirl.php +++ pear/PECL/imagick/examples/swirl.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_swirl( $handle, 180 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_swirl() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/threshold.php +++ pear/PECL/imagick/examples/threshold.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_threshold( $handle, 25.5 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_threshold() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/unsharpmask.php +++ pear/PECL/imagick/examples/unsharpmask.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_unsharpmask( $handle, 10, 5, 30, 25 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_unsharpmask() 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 ; } print "Done!<BR>\n" ; ?> Index: pear/PECL/imagick/examples/wave.php +++ pear/PECL/imagick/examples/wave.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_wave( $handle, 20, 60 ) ) { $reason = imagick_failedreason( $handle ) ; $description = imagick_faileddescription( $handle ) ; print "imagick_wave() 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 ; } print "Done!<BR>\n" ; ?>
« previous php.pear.cvs (#7724) next »