tags:

views:

816

answers:

2

HEllo,

I am trying to rotate a circular image around the center and then cut off the sides. I see the imagerotate function, but it does not seem to rotate about centre.

Anyone have any suggestions?

Thank you.

Update: Since it is a circle, I want to cut off the edges and keep my circle in the same dimensions.

A: 

According to the PHP manual imagerotate() page:

The center of rotation is the center of the image, and the rotated image is scaled down so that the whole rotated image fits in the destination image - the edges are not clipped.

Perhaps the visible center of the image is not the actual center?

karim79
+1  A: 

The documentation says that it does rotate around the center.

Unfortunately it also says that it will scale the image so that it still fits. That means that whatever you do this function will change the size of your internal circular image.

You could (relatively easily) calculate how much scaling down will happen and then prescale the image up appropriately beforehand.

If you have the PHP "ImageMagick" functions available you can use those instead - they apparently don't scale the image.

Alnitak
Resizing first and *then* rotating should yield better quality images.
soulmerge
indeed - yes. the GD image rotate will always be a scale down, so better to scale up first. will edit to fix.
Alnitak