note 101363 added to function.imagick-fximage

From: Date: Sun, 12 Dec 2010 17:11:36 +0000
Subject: note 101363 added to function.imagick-fximage
Groups: php.notes 
Request: Send a blank email to php-notes+get-174826@lists.php.net to get a copy of this message
This function doesn't return TRUE on success! It's return the actual Imagick object of the processed image. So you should write: <?php $im = $im->fxImage($effect_expression); ?> Here is a usefull example: -generate 100x100 "pseudo image" of a checkboard pattern -applying a fisheye lens (aka "barrel distortion") effect to the image <?php /* Create new object */ $im = new Imagick(); /* Create new checkerboard pattern */ $im->newPseudoImage(100, 100, "pattern:checkerboard"); /* Set the image format to png */ $im->setImageFormat('png'); /* Fill background area with transparent */ $trans = Imagick::VIRTUALPIXELMETHOD_TRANSPARENT; $im->setImageVirtualPixelMethod($trans); /* Activate matte */ $im->setImageMatte(true); $distort_expression = 'kk=w*0.5; ll=h*0.5; dx=(i-kk); dy=(j-ll); aa=atan2(dy,dx); rr=hypot(dy,dx); rs=rr*rr/hypot(kk,ll); px=kk+rs*cos(aa); py=ll+rs*sin(aa); p{px,py}'; /* Perform the distortion */ $im = $im->fxImage($distort_expression); /* Ouput the image */ header("Content-Type: image/png"); echo $im; ?> The expression was copied from http://scottpenberthy.com/2008/09/05/fisheye-effect-in-imagemagick/ visit his blog to understand the expression. See full documentation about the expression sytax in the official documentation: http://www.imagemagick.org/script/fx.php ---- Server IP: 69.147.83.197 Probable Submitter: 95.86.78.196 ---- Manual Page -- http://www.php.net/manual/en/function.imagick-fximage.php Edit -- https://master.php.net/note/edit/101363 Del: integrated -- https://master.php.net/note/delete/101363/integrated Del: useless -- https://master.php.net/note/delete/101363/useless Del: bad code -- https://master.php.net/note/delete/101363/bad+code Del: spam -- https://master.php.net/note/delete/101363/spam Del: non-english -- https://master.php.net/note/delete/101363/non-english Del: in docs -- https://master.php.net/note/delete/101363/in+docs Del: other reasons-- https://master.php.net/note/delete/101363 Reject -- https://master.php.net/note/reject/101363 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#174826) next »