Search code examples
phpimagemagickimagick

ImageMagick Draw translate coordinates


I have generated a polygon using coordinates, which is stored in an ImagickDraw object. I would like to rotate a few copies of the object and then draw them at various positions onto my image.

I am using imagick 3.1.0rc1 and ImageMagick 6.7.6-5.

Here's what I am using:

$sprite = new ImagickDraw();
$sprite->polygon($coords) //array of coordinates

$sprite->rotate(-90); //Doesn't seem to rotate
$sprite->translate($x, $y); //Doesn't seem to translate

$im->drawImage($sprite);

The problem is that for some reason, rotate and translate does nothing. Am I doing something wrong? Or does rotate and translate not do what I think it's suppose to do?


Solution

  • Seems like translate was not the way to do it.

    I ended up generating the sprite in a new ImagickDraw object and then drew it onto my main image using compositeImage() into the appropriate position.