def AffineRotate(theta,new_size,center=None,filter=BILINEAR):
'''
Create a rotation about the origin.
@param theta: the angle to rotate the image in radians.
@param new_size: new size for the image.
@param filter: PIL filter to use.
'''
matrix = array([[math.cos(theta),-math.sin(theta),0],[math.sin(theta),math.cos(theta),0],[0,0,1]],'d')
rotate = AffineTransform(matrix,new_size,filter)
if center == None:
return rotate
else:
return AffineTranslate(center.X(),center.Y(),new_size)*rotate*AffineTranslate(-center.X(),-center.Y(),new_size)
评论列表
文章目录