英文:
Pillow rotate not quite right
问题
原文中的代码部分已被排除,以下是翻译好的内容:
原图:
旋转 -90 度后的图像:
block = scene.read_block()
image = PILImage.fromarray(block)
image_rotate = image.rotate(-90)
buf = BytesIO()
image_rotate.save(buf, "JPEG", quality=90)
return buf.getvalue()
视口没有旋转,只有图像内容发生了旋转。
英文:
It is hard to explain so please look at the image. It appears to rotate the data within the image but not the image itself.
original:
Rotated -90:
block = scene.read_block()
image = PILImage.fromarray(block)
image_rotate = image.rotate(-90)
buf = BytesIO()
image_rotate.save(buf, "JPEG", quality=90)
return buf.getvalue()
The viewport didn't rotate only the image inside.
Thanks
答案1
得分: 2
需要使用 expand=True
来更改大小。
image.rotate(-90, expand=True)
你可以在文档中找到相关信息。
英文:
you need to use expand=True to change the size
image.rotate(-90, expand=True)
it is in the documentation
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论