how do i catch error in imagick

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
skyjan

how do i catch error in imagick

Post by skyjan »

hello

just wondering how do i return/catch the error in imagick

function imagehere()
{
$im = new Imagick();
/* Create empty canvas */
$im->newImage( 100, 100, "white", "jpg" );//png,jpg,gif.. image format
/* Create the object used to draw */
$draw = new ImagickDraw();
/* Set the button color.
Changing this value changes the color of the button */

$draw->setFillColor( new ImagickPixel("#FFFFFF") ); // BOX COLOR //#4096EE
/* Create the rectangle */
$draw->rectangle( 0,0, 100, 100 );


/* assuming there is still codes here
in any case there is an error
*/
$draw->setFont( "Fonts/arial.tt" ); // This generate error
$draw->setFontSize( 15 );

/* the question is how do i catch the error that the font is missing since i want to return an error value */




}
mkoppanen
Posts: 309
Joined: 2007-06-09T07:06:32-07:00

Re: how do i catch error in imagick

Post by mkoppanen »

Use a try-catch block
Mikko Koppanen
My blog: http://valokuva.org
Post Reply