Reputation: 3958
I am wondering if it is possible to rotate an image using a reference point.
For example, rotating this image by 30 degrees:
instead of having:
I would like to have:
which means rotating the image on the bottom-left point.
I would do this overlapping the rectangle to the original image if needed, and rotating it as needed only after.
Upvotes: 1
Views: 1035
Reputation: 17417
The ImageMagick extension can do this, using the DISTORTION_SCALEROTATETRANSLATE option. You might need to tweak the coordinates and angle a bit to fit your needs.
<?php
$im = new Imagick('sample.png');
$args = array(
0, // X-point
300, // Y-point
1, // Scale
-45, // Rotation
);
$im->distortImage(Imagick::DISTORTION_SCALEROTATETRANSLATE, $args, false);
$im->setImageFormat('png');
file_put_contents('rotated.png', (string) $im);
Upvotes: 4