note 101363 rejected from function.imagick-fximage by danbrown

From: Date: Sun, 12 Dec 2010 17:37:30 +0000
Subject: note 101363 rejected from function.imagick-fximage by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174827@lists.php.net to get a copy of this message
Note Submitter: dvb at stackoverflow dot com ---- 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

« previous php.notes (#174827) next »