Error distortImage with Mikko example

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
badabou
Posts: 54
Joined: 2008-06-23T06:12:24-07:00

Error distortImage with Mikko example

Post by badabou »

Hello,

I have a problem with the function distortImage.

In fact, I just copied / pasted the example below on the mikko's blog and I have this error :

Fatal error: Uncaught exception 'ImagickException' with message 'invalid argument for option PerspectiveProjection : 'Needs 8 coefficient values'' in ...

Code: Select all

<?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 */
$im->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
 
/* Activate matte */
$im->setImageMatte(true);
 
/* Control points for the distortion */
$controlPoints = array( 10, 10, 
                        10, 5,
 
                        10, $im->getImageHeight() - 20,
                        10, $im->getImageHeight() - 5,
 
                        $im->getImageWidth() - 10, 10,
                        $im->getImageWidth() - 10, 20,
 
                        $im->getImageWidth() - 10, $im->getImageHeight() - 10,
                        $im->getImageWidth() - 10, $im->getImageHeight() - 30); 
 
/* Perform the distortion */  
$im->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, true);
 
/* Ouput the image */   
header("Content-Type: image/png");
echo $im;
?> 
Thank you for your help.
spooky25

Re: Error distortImage with Mikko example

Post by spooky25 »

Probably not the kind of helpful response you prefer, but I get the same error when I run the code you posted. I'm running Image Magick 6.5.1 Q16 and ( if I remember correctly ) php_imagick_dyn-Q16.dll.
badabou
Posts: 54
Joined: 2008-06-23T06:12:24-07:00

Re: Error distortImage with Mikko example

Post by badabou »

Thank you for your reply.

Some details :

My configuration with which I have this problem is :

Windows XP
Imagick module version 2.2.1-dev (php_imagick_dyn-Q16.dll)
ImageMagick 6.5.1-6



When I use the same script on my linux server, it runs at half, there was no transparency (Image attached).
Attachments
test.png
test.png (15 KiB) Viewed 15075 times
esm723

Re: Error distortImage with Mikko example

Post by esm723 »

Hey guys,

This problem has occurred before, so check out the thread there so that we can keep all of the info in one place.

viewtopic.php?f=18&t=9955&p=59631#p59631
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Error distortImage with Mikko example

Post by fmw42 »

If your perspective is so exaggerated that you are seeing the horizon, then you need to set the mattecolor. see http://www.imagemagick.org/Usage/distorts/#horizon
Post Reply