php - Changing the center of rotation of Imagerotate -
imagerotate rotates image using given angle in degrees.
the center of rotation center of image, , rotated image may have different dimensions original image.
how change center of rotation coordinate x_new , y_new , avoid automatic resizing?
example: rotation around red dot.
first idea comes mind move image new center @ x_new, y_new rotate , move back.
assumptions:
0 < x_new < w 0 < y_new < h
pseudocode:
new_canter_x = max(x_new, w - x_new) new_center_y = max(y_new, h - y_new) create new image (plain or transparent background): width = new_canter_x * 2 height = new_center_y * 2 copy old image new 1 coords: new_center_x - x_new new_center_y - y_new imagerotate new image.
now have cut part interested in out of it.
Comments
Post a Comment