eZ Publish  [trunk]
ezimageinterface.php
Go to the documentation of this file.
00001 <?php
00002 /**
00003  * File containing the eZImageInterface class.
00004  *
00005  * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved.
00006  * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
00007  * @version //autogentag//
00008  * @package lib
00009  */
00010 
00011 /*! \defgroup eZImageObject Image object and layer handling */
00012 
00013 /*!
00014   \class eZImageInterface ezimageinterface.php
00015   \brief Base interface for all image object and layer classes
00016 
00017 */
00018 
00019 class eZImageInterface
00020 {
00021     function eZImageInterface( $imageObjectRef = null, $imageObject = null, $width = false, $height = false )
00022     {
00023         $this->ImageObjectRef = $imageObjectRef;
00024         $this->ImageObject = $imageObject;
00025         $this->Width = $width;
00026         $this->Height = $height;
00027         $this->AlternativeText = '';
00028         $this->IsTrueColor = null;
00029         $this->Palette = array();
00030         $this->PaletteIndex = array();
00031         $this->StoredPath = false;
00032         $this->Font = null;
00033         $this->IsProcessed = false;
00034     }
00035 
00036     /*!
00037      \return true if the image is true color. True color images behave differently from palette based
00038      and GD has problems with mixing the two types.
00039     */
00040     function isTruecolor()
00041     {
00042         return $this->IsTrueColor;
00043     }
00044 
00045     /*!
00046      \private
00047      \return a map array which maps from an attribute name to a member variable.
00048      Used by attributes, hasAttribute and attribute.
00049     */
00050     function attributeMemberMap()
00051     {
00052         return array( 'filepath' => 'StoredPath',
00053                       'filename' => 'StoredFile',
00054                       'width' => 'Width',
00055                       'height' => 'Height',
00056                       'alternative_text' => 'AlternativeText' );
00057     }
00058 
00059     /*!
00060      \private
00061      \return a map array which maps from an attribute name to a member function.
00062      Used by attributes, hasAttribute and attribute.
00063     */
00064     function attributeFunctionMap()
00065     {
00066         return array( 'imagepath' => 'imagePath',
00067                       'has_size' => 'hasSize' );
00068     }
00069 
00070     /*!
00071      \return an array with attribute names which this object supports.
00072     */
00073     function attributes()
00074     {
00075         return array_merge( array_keys( eZImageInterface::attributeMemberMap() ),
00076                             array_keys( eZImageInterface::attributeFunctionMap() ) );
00077     }
00078 
00079     /*!
00080      \return true if the attribute \a $name exists.
00081     */
00082     function hasAttribute( $name )
00083     {
00084         $attributeMemberMap = eZImageInterface::attributeMemberMap();
00085         if ( isset( $attributeMemberMap[$name] ) )
00086             return true;
00087         $attributeFunctionMap = eZImageInterface::attributeFunctionMap();
00088         if ( isset( $attributeFunctionMap[$name] ) )
00089             return true;
00090         return false;
00091     }
00092 
00093     /*!
00094      \return the attribute with name \a $name or \c null if the attribute does not exist.
00095     */
00096     function attribute( $name )
00097     {
00098         $attributeMemberMap = eZImageInterface::attributeMemberMap();
00099         if ( isset( $attributeMemberMap[$name] ) )
00100         {
00101             $member = $attributeMemberMap[$name];
00102             if ( isset( $this->$member ) )
00103                 return $this->$member;
00104             eZDebug::writeWarning( 'The member variable $member was not found for attribute $name', __METHOD__ );
00105             return null;
00106         }
00107         $attributeFunctionMap = eZImageInterface::attributeFunctionMap();
00108         if ( isset( $attributeFunctionMap[$name] ) )
00109         {
00110             $function = $attributeFunctionMap[$name];
00111             if ( method_exists( $this, $function ) )
00112                 return $this->$function();
00113             eZDebug::writeWarning( 'The member function $function was not found for attribute $name', __METHOD__ );
00114             return null;
00115         }
00116         eZDebug::writeError( "Attribute '$name' does not exist", __METHOD__ );
00117         return null;
00118     }
00119 
00120     /*!
00121      \return true if the image object has been processed, this means that
00122              image has been rendered.
00123     */
00124     function isProcessed()
00125     {
00126         return $this->IsProcessed;
00127     }
00128 
00129     /*!
00130       \return true if the width and height of the image has been set.
00131     */
00132     function &hasSize()
00133     {
00134         $hasSize = ( $this->Width !== false and $this->Height !== false );
00135         return $hasSize;
00136     }
00137 
00138     /*!
00139      \return the path to the image file including the file.
00140     */
00141     function &imagePath()
00142     {
00143         $imagePath = $this->StoredPath . '/' . $this->StoredFile;
00144         return $imagePath;
00145     }
00146 
00147     /*!
00148      Sets the alternative text to \a $text, it will be used for describing the
00149      image and can be used by browsers that cannot view images.
00150     */
00151     function setAlternativeText( $text )
00152     {
00153         $this->AlternativeText = $text;
00154     }
00155 
00156     /*!
00157      \return the alternative text for the image.
00158      \sa setAlternativeText
00159     */
00160     function alternativeText()
00161     {
00162         return $this->AlternativeText;
00163     }
00164 
00165     /*!
00166      \protected
00167      Registers the GD image object \a $image for destruction upon script end.
00168      This makes sure that image resources are cleaned up after use.
00169      \return a reference for the image which can be used in unregisterImage later on. Returns false if resource can't be registered.
00170     */
00171     static function registerImage( $image )
00172     {
00173         if ( !is_resource( $image ) or get_resource_type( $image ) != 'gd' )
00174             return false;
00175         $imageObjectRef = md5( microtime() );
00176         $createdImageArray =& $GLOBALS['eZImageCreatedArray'];
00177         if ( !is_array( $createdImageArray ) )
00178         {
00179             $createdImageArray = array();
00180             register_shutdown_function( 'eZGlobalImageCleanupFunction' );
00181         }
00182         $createdImageArray[$imageObjectRef] = $image;
00183         return $imageObjectRef;
00184     }
00185 
00186     /*!
00187      Tries to unregister the image with reference \a $imageRef
00188     */
00189     static function unregisterImage( $imageRef )
00190     {
00191         $createdImageArray =& $GLOBALS['eZImageCreatedArray'];
00192         if ( !is_array( $createdImageArray ) )
00193             return;
00194         if ( !isset( $createdImageArray[$imageRef] ) )
00195             return;
00196         unset( $createdImageArray[$imageRef] );
00197     }
00198 
00199     /*!
00200      Cleans up all registered images.
00201     */
00202     static function cleanupRegisteredImages()
00203     {
00204         $createdImageArray =& $GLOBALS['eZImageCreatedArray'];
00205         if ( !is_array( $createdImageArray ) )
00206             return;
00207         foreach ( array_keys( $createdImageArray ) as $createImageKey )
00208         {
00209             $createdImage = $createdImageArray[$createImageKey];
00210             if ( is_resource( $createdImage ) and get_resource_type( $createdImage ) == 'gd' )
00211                 ImageDestroy( $createdImage );
00212         }
00213     }
00214 
00215     /*!
00216      Tries to load the PNG image from the path \a $storedPath and file \a $storedFile into
00217      the current image object.
00218      \return true if succesful.
00219     */
00220     function loadPNG( $storedPath, $storedFile )
00221     {
00222         if ( !function_exists( 'ImageCreateFromPNG' ) )
00223             return false;
00224         $this->ImageObject = ImageCreateFromPNG( $storedPath . '/' . $storedFile );
00225         if ( $this->ImageObject )
00226         {
00227             $this->ImageObjectRef = eZImageInterface::registerImage( $this->ImageObject );
00228             return true;
00229         }
00230         return false;
00231     }
00232 
00233     /*!
00234      Tries to load the JPEG image from the path \a $storedPath and file \a $storedFile into
00235      the current image object.
00236      \return true if succesful.
00237     */
00238     function loadJPEG( $storedPath, $storedFile )
00239     {
00240         $this->ImageObject = ImageCreateFromJPEG( $storedPath . '/' . $storedFile );
00241         if ( $this->ImageObject )
00242         {
00243             $this->ImageObjectRef = eZImageInterface::registerImage( $this->ImageObject );
00244             return true;
00245         }
00246         return false;
00247     }
00248 
00249     /*!
00250      Tries to load the GIF image from the path \a $storedPath and file \a $storedFile into
00251      the current image object.
00252      \return true if succesful.
00253     */
00254     function loadGIF( $storedPath, $storedFile )
00255     {
00256         if ( !function_exists( 'ImageCreateFromGIF' ) )
00257             return false;
00258         $this->ImageObject = ImageCreateFromGIF( $storedPath . '/' . $storedFile );
00259         if ( $this->ImageObject )
00260         {
00261             $this->ImageObjectRef = eZImageInterface::registerImage( $this->ImageObject );
00262             return true;
00263         }
00264         return false;
00265     }
00266 
00267     /*!
00268      Tries to load the stored image set by setStoredFile().
00269      If the stored type is not set it will try all formats until one succeeds.
00270      \return true if succesful.
00271     */
00272     function load()
00273     {
00274         if ( $this->ImageObject !== null and
00275              $this->ImageObjectRef !== null )
00276             return;
00277         switch( $this->StoredType )
00278         {
00279             case 'png':
00280             {
00281                 return $this->loadPNG( $this->StoredPath, $this->StoredFile );
00282             } break;
00283 
00284             case 'jpg':
00285             {
00286                 return $this->loadJPEG( $this->StoredPath, $this->StoredFile );
00287             } break;
00288 
00289             case 'gif':
00290             {
00291                 return $this->loadGIF( $this->StoredPath, $this->StoredFile );
00292             } break;
00293 
00294             default:
00295             {
00296                 if ( @$this->loadPNG( $this->StoredPath, $this->StoredFile ) )
00297                     return true;
00298                 else if ( @$this->loadJPEG( $this->StoredPath, $this->StoredFile ) )
00299                     return true;
00300                 else if ( @$this->loadGIF( $this->StoredPath, $this->StoredFile ) )
00301                     return true;
00302                 eZDebug::writeError( 'Image format not supported: ' . $this->StoredType, __METHOD__ );
00303             }
00304         }
00305         return false;
00306     }
00307 
00308     /*!
00309      Cleans up the current image object if it is set.
00310     */
00311     function destroy()
00312     {
00313         if ( $this->ImageObjectRef === null )
00314             return;
00315         if ( is_resource( $this->ImageObject ) and get_resource_type( $this->ImageObject ) == 'gd' )
00316             ImageDestroy( $this->ImageObject );
00317         eZImageInterface::unregisterImage( $this->ImageObjectRef );
00318         unset( $this->ImageObject );
00319         $this->ImageObject = null;
00320         $this->ImageObjectRef = null;
00321     }
00322 
00323     /*!
00324      \return the current image object, if \a $createMissing is true if will
00325              run the image processing to make sure it is created.
00326              Returns \c null if no image is available.
00327      \sa imageObjectInternal
00328     */
00329     function imageObject( $createMissing = true )
00330     {
00331         if ( $this->ImageObject === null or
00332              $this->ImageObjectRef === null )
00333         {
00334             if ( $createMissing )
00335             {
00336                 if ( $this->StoredFile != '' )
00337                 {
00338                     $this->process();
00339                 }
00340             }
00341         }
00342         return $this->ImageObject;
00343     }
00344 
00345     /*!
00346      \protected
00347      \return the current image object, will create an empty image object if \a $createMissing
00348              is true and the image object is not already created.
00349      \sa imageObject
00350     */
00351     function imageObjectInternal( $createMissing = true )
00352     {
00353         if ( $this->ImageObject === null or
00354              $this->ImageObjectRef === null )
00355         {
00356             if ( $createMissing )
00357                 $this->create( $this->Width, $this->Height );
00358         }
00359         return $this->ImageObject;
00360     }
00361 
00362     /*!
00363      Makes sure the image object is processed and rendered.
00364      Calls processImage() which is implemented by all descendants of this class to do the real work.
00365     */
00366     function process()
00367     {
00368         if ( $this->processImage() )
00369             $this->IsProcessed = true;
00370     }
00371 
00372     /*!
00373      \virtual
00374      Tries to render an image onto the image object, each inheriting class must override this to do
00375      somethign sensible. By default it will try to load the stored image if one is set.
00376      \return true if the image was succesfully processed.
00377     */
00378     function processImage()
00379     {
00380         if ( $this->StoredFile == '' )
00381             return true;
00382         $fileArray = array( $this->StoredPath, $this->StoredFile );
00383         $filePath = eZDir::path( $fileArray );
00384         $imageinfo = getimagesize( $filePath );
00385         if ( $imageinfo )
00386         {
00387             $width = $imageinfo[0];
00388             $height = $imageinfo[1];
00389             if ( $this->load() )
00390             {
00391                 $this->Width = $width;
00392                 $this->Height = $height;
00393                 return true;
00394             }
00395             else
00396                 eZDebug::writeWarning( "Image failed to load '$filePath'", __METHOD__ );
00397         }
00398         else
00399             eZDebug::writeWarning( "No image info could be extracted from '$filePath'", __METHOD__ );
00400         return false;
00401     }
00402 
00403     /*!
00404      Stores the current image object to disk, the image is stored in the path \a $filePath with filename \a $fileName.
00405      The parameter \a $type determines the image format, supported are \c png and \c jpg.
00406      \return true if the image was stored correctly.
00407     */
00408     function store( $fileName, $filePath, $type )
00409     {
00410         if ( !$this->IsProcessed )
00411             $this->process();
00412         $imageObject = $this->imageObject();
00413         switch( $type )
00414         {
00415             case 'png':
00416             {
00417                 if ( !file_exists( $filePath ) )
00418                 {
00419                     eZDir::mkdir( $filePath, false, true );
00420                 }
00421                 $fileFullPath = eZDir::path( array( $filePath, $fileName ) );
00422                 ImagePNG( $imageObject, $fileFullPath );
00423                 $this->StoredPath = $filePath;
00424                 $this->StoredFile = $fileName;
00425                 $this->StoredType = $type;
00426                 return true;
00427             } break;
00428 
00429             case 'jpg':
00430             {
00431                 if ( !file_exists( $filePath ) )
00432                 {
00433                     eZDir::mkdir( $filePath, false, true );
00434                 }
00435                 ImageJPEG( $imageObject, eZDir::path( array( $filePath, $fileName ) ) );
00436                 $this->StoredPath = $filePath;
00437                 $this->StoredFile = $fileName;
00438                 $this->StoredType = $type;
00439                 return true;
00440             } break;
00441 
00442             default:
00443             {
00444                 eZDebug::writeError( 'Image format not supported: ' . $type, __METHOD__ );
00445             }
00446         }
00447         return false;
00448     }
00449 
00450     /*!
00451      \static
00452      \return true if GD2 is installed.
00453     */
00454     static function hasGD2()
00455     {
00456         $imageINI = eZINI::instance( 'image.ini' );
00457         return $imageINI->variable( 'GDSettings', 'HasGD2' ) == 'true';
00458 //         $testGD = get_extension_funcs( "gd" ); // Grab function list
00459 //         if ( !$testGD )
00460 //         {
00461 // //             echo "GD not even installed.";
00462 //             return false;
00463 //         }
00464 //         if ( in_array( "imagegd2",
00465 //                        $testGD ) )
00466 //             return true;
00467 //         return false;
00468     }
00469 
00470     /*!
00471      \static
00472      \private
00473      Creates an image with size \a $width and \a $height using GD and returns it.
00474     */
00475     static function createImage( $width, $height, &$useTruecolor )
00476     {
00477         if ( $useTruecolor === null )
00478         {
00479 //             print( "has GD2='" . eZImageInterface::hasGD2() . "'<br/>" );
00480             $useTruecolor = eZImageInterface::hasGD2();
00481         }
00482         if ( $useTruecolor and
00483              !function_exists( 'ImageCreateTrueColor' ) )
00484         {
00485             eZDebug::writeWarning( 'Function ImageCreateTrueColor does not exist, cannot create true color images', __METHOD__ );
00486             $useTruecolor = false;
00487         }
00488         if ( $useTruecolor )
00489             $imageObject = ImageCreateTrueColor( $width, $height );
00490         else
00491             $imageObject = ImageCreate( $width, $height );
00492         return $imageObject;
00493     }
00494 
00495     /*!
00496      Creates a new image object with width \a $width and height \a $height.
00497      \a $useTruecolor determines the type of image, if \c true it will be truecolor,
00498      if \c false it will be palette based or if \c null it will create it depending on
00499      the GD version. GD 2 will get truecolor while < 2 will get palette based.
00500     */
00501     function create( $width, $height, $useTruecolor = null )
00502     {
00503         if ( $this->ImageObject !== null and
00504              $this->ImageObjectRef !== null )
00505         {
00506             $this->destroy();
00507         }
00508         unset( $this->ImageObject );
00509         $this->ImageObject = eZImageInterface::createImage( $width, $height, $useTruecolor );
00510         $this->Width = $width;
00511         $this->Height = $height;
00512 //         eZDebug::writeDebug( $this->ImageObject, 'create' );
00513         $this->IsTrueColor = $useTruecolor;
00514         $this->ImageObjectRef = eZImageInterface::registerImage( $this->ImageObject );
00515     }
00516 
00517     /*!
00518      Copies the image from \a $image as the current image object.
00519     */
00520     function __clone()
00521     {
00522         $this->cloneImage( $this->imageObject(), $this->width(), $this->height(),
00523                            $this->isTruecolor() );
00524     }
00525 
00526     /*!
00527      Clones the image object \a $imageObject with width \a $width, height \a $height
00528      and truecolor settings \a $useTruecolor.
00529     */
00530     function cloneImage( $imageObject, $width, $height, $useTruecolor = null )
00531     {
00532         if ( $this->ImageObject !== null and
00533              $this->ImageObjectRef !== null )
00534         {
00535             $this->destroy();
00536         }
00537         $this->ImageObject = eZImageInterface::createImage( $width, $height, $useTruecolor );
00538         $this->IsTrueColor = $useTruecolor;
00539         $this->ImageObjectRef = eZImageInterface::registerImage( $this->ImageObject );
00540         ImageCopy( $this->ImageObject, $imageObject, 0, 0, 0, 0, $width, $height );
00541     }
00542 
00543     /*!
00544      \return the current width of the image or \a false if no size has been set.
00545     */
00546     function width()
00547     {
00548         return $this->Width;
00549     }
00550 
00551     /*!
00552      \return the current height of the image or \a false if no size has been set.
00553     */
00554     function height()
00555     {
00556         return $this->Height;
00557     }
00558 
00559     /*!
00560      Sets the width of the image to \a $w.
00561     */
00562     function setWidth( $w )
00563     {
00564         $this->Width = $w;
00565     }
00566 
00567     /*!
00568      Sets the height of the image to \a $h.
00569     */
00570     function setHeight( $h )
00571     {
00572         $this->Height = $h;
00573     }
00574 
00575     /*!
00576      Sets the path, file and type of the stored file.
00577      These settings will be used by load().
00578     */
00579     function setStoredFile( $file, $path, $type )
00580     {
00581         $this->StoredFile = $file;
00582         $this->StoredPath = $path;
00583         $this->StoredType = $type;
00584     }
00585 
00586     /*!
00587      Sets the current font object to \a $font.
00588     */
00589     function setFont( $font )
00590     {
00591         $this->Font = $font;
00592     }
00593 
00594     /*!
00595      \return the current font object or \c null if not font object has been set.
00596     */
00597     function font()
00598     {
00599         return $this->Font;
00600     }
00601 
00602     /*!
00603      Copies the image \a $imageObject with size \a $sourceWidth and \a $sourceHeight
00604      and position \a $sourceX and \a $sourceY onto the destination image \a $destinationImageObject
00605      at position \a $destinationX and \a $destinationY.
00606     */
00607     function copyImage( $destinationImageObject, $imageObject,
00608                         $destinationX, $destinationY,
00609                         $sourceWidth, $sourceHeight, $sourceX = 0, $sourceY = 0 )
00610     {
00611         ImageCopy( $destinationImageObject, $imageObject,
00612                    $destinationX, $destinationY,
00613                    $sourceX, $sourceY, $sourceWidth, $sourceHeight );
00614     }
00615 
00616     /*!
00617      Merges the image \a $imageObject with size \a $sourceWidth and \a $sourceHeight
00618      and position \a $sourceX and \a $sourceY with the destination image \a $destinationImageObject
00619      at position \a $destinationX and \a $destinationY.
00620      The merged image is placed on the \a $destinationImageObject.
00621      \param $transparency determines how transparent the source image is. 0 is the same as copyImage
00622             and 100 is the same is no copy is made.
00623     */
00624     function mergeImage( $destinationImageObject, $imageObject,
00625                          $destinationX, $destinationY,
00626                          $sourceWidth, $sourceHeight, $sourceX = 0, $sourceY = 0,
00627                          $transparency = 0 )
00628     {
00629         $percent = 100 - $transparency;
00630         ImageCopyMerge( $destinationImageObject, $imageObject,
00631                         $destinationX, $destinationY,
00632                         $sourceX, $sourceY, $sourceWidth, $sourceHeight,
00633                         $percent );
00634     }
00635 
00636     /*!
00637      Alpha blends the image \a $imageObject with size \a $sourceWidth and \a $sourceHeight
00638      and position \a $sourceX and \a $sourceY onto the destination image \a $destinationImageObject
00639      at position \a $destinationX and \a $destinationY.
00640      \note This required GD2 and uses color 0 (black) for blending.
00641     */
00642     function blendImage( $destinationImageObject, $imageObject,
00643                          $destinationX, $destinationY,
00644                          $sourceWidth, $sourceHeight, $sourceX = 0, $sourceY = 0 )
00645     {
00646         ImageAlphaBlending( $destinationImageObject, true );
00647         ImageCopy( $destinationImageObject, $imageObject,
00648                    $destinationX, $destinationY,
00649                    $sourceX, $sourceY, $sourceWidth, $sourceHeight );
00650     }
00651 
00652     function merge( $imageObject, $x, $y, $width, $height )
00653     {
00654         if ( $this->ImageObject === null or
00655              $this->ImageObjectRef === null )
00656             return false;
00657 //         ImageAlphaBlending( $this->ImageObject, true );
00658         imagecolortransparent( $imageObject, 0 );
00659 //         ImageCopy( $this->ImageObject, $imageObject, $x, $y, 0, 0, $width, $height );
00660         ImageCopyMerge( $this->ImageObject, $imageObject, $x, $y, 0, 0, $width, $height, 50 );
00661     }
00662 
00663     /*!
00664      Clears the image object with color \a $color.
00665      If \a $color is not specified it will use the first color set.
00666     */
00667     function clear( $color = false )
00668     {
00669         if ( $color === false )
00670         {
00671             if ( count( $this->PaletteIndex ) > 0)
00672                 $color = $this->PaletteIndex[0];
00673             else
00674                 $color = 'bgcol';
00675         }
00676         if ( is_string( $color ) )
00677             $color = $this->color( $color );
00678         ImageFilledRectangle( $this->ImageObject, 0, 0, $this->Width, $this->Height, $color );
00679     }
00680 
00681     /*!
00682      Allocates the color \a $red, \a $green and \a $blue with name \a $name and returns it.
00683      Will return the palette index for palette based images and the color value for true color.
00684     */
00685     function allocateColor( $name, $red, $green, $blue )
00686     {
00687         if ( isset( $this->Palette[$name] ) )
00688         {
00689             eZDebug::writeError( 'Color already defined: ' . $name, __METHOD__ );
00690             return null;
00691         }
00692         $red = max( 0, min( 255, $red ) );
00693         $green = max( 0, min( 255, $green ) );
00694         $blue = max( 0, min( 255, $blue ) );
00695         $color = ImageColorAllocate( $this->ImageObject, $red, $green, $blue );
00696         $this->Palette[$name] = $color;
00697         $this->PaletteIndex[] = $color;
00698         return $color;
00699     }
00700 
00701     /*!
00702      \return the color for the name \a $name.
00703     */
00704     function color( $name )
00705     {
00706         if ( !isset( $this->Palette[$name] ) )
00707         {
00708             eZDebug::writeError( 'Color not defined: ' . $name, __METHOD__ );
00709             return null;
00710         }
00711         return $this->Palette[$name];
00712     }
00713 
00714     /*!
00715      \return the color used for text drawing.
00716     */
00717     function textColor()
00718     {
00719         return $this->TextColor;
00720     }
00721 
00722     /*!
00723      Sets the color used for text drawing to \a $textColor.
00724     */
00725     function setTextColor( $textColor )
00726     {
00727         $this->TextColor = $textColor;
00728     }
00729 
00730     /*!
00731      Draws the text \a $text using the font \a $font and color \a $textColor
00732      at position \a $x and \a $y with angle \a $angle.
00733      If \a $imageObject is specified it will use that for drawing instead of
00734      the current image.
00735     */
00736     function drawText( &$font, $textColor, $text, $x, $y, $angle,
00737                        $imageObject = null )
00738     {
00739         if ( !$font )
00740         {
00741             eZDebug::writeWarning( 'Cannot render text, no font is set', __METHOD__ );
00742             return false;
00743         }
00744         if ( !$textColor )
00745         {
00746             eZDebug::writeWarning( 'Cannot render text, no text color is set', __METHOD__ );
00747             return false;
00748         }
00749         if ( is_string( $textColor ) )
00750             $textColor = $this->color( $textColor );
00751         if ( $textColor === null )
00752         {
00753             eZDebug::writeWarning( 'Cannot render text, invalid text color', __METHOD__ );
00754             return false;
00755         }
00756 
00757         $x += $font->xAdjustment();
00758         $y += $font->yAdjustment();
00759 
00760         if ( $imageObject === null )
00761             $imageObject = $this->ImageObject;
00762 
00763         ImageTTFText( $imageObject, $font->pointSize(), $angle, $x, $y,
00764                       $textColor, $font->realFile(), $text );
00765     }
00766 
00767     /// \privatesection
00768     public $Width;
00769     public $Height;
00770     public $Font;
00771     public $ImageObject;
00772     public $ImageObjectRef;
00773     public $StoredFile;
00774     public $StoredPath;
00775     public $StoredType;
00776     public $PaletteIndex;
00777     public $Palette;
00778     public $AlternativeText;
00779     public $IsTrueColor;
00780     public $IsProcessed;
00781 }
00782 
00783 /*!
00784  Global function for eZImageInterface. It will be called at the end of the script execution
00785  and will cleanup all images left behind.
00786 */
00787 function eZGlobalImageCleanupFunction()
00788 {
00789     eZImageInterface::cleanupRegisteredImages();
00790 }
00791 
00792 ?>