如何用Python编写可以旋转图像的函数(cImage)
如何编写代码?我只能想到这个:如何用Python编写可以旋转图像的函数(cImage),python,Python,如何编写代码?我只能想到这个: def rotateImage90CW(image): pic = FileImage(image) oldw = pic.getWidth() oldh = pic.getHeight() newIm = EmptyImage(oldw,oldh) for row in range (oldh): for col in range(oldw): oldPixel = pic.getPixel(col,row) newIm.
def rotateImage90CW(image):
pic = FileImage(image)
oldw = pic.getWidth()
oldh = pic.getHeight()
newIm = EmptyImage(oldw,oldh)
for row in range (oldh):
for col in range(oldw):
oldPixel = pic.getPixel(col,row)
newIm.setPixel(oldw-row,col,oldPixel)
newIm.draw(myWin)
如果您使用PIL/枕头:
from PIL import Image
im = Image.open(image)
im.rotate(90).show()
在您的示例中,oldw row应为“row”