Pillow 旋转不太正确

huangapple go评论58阅读模式
英文:

Pillow rotate not quite right

问题

原文中的代码部分已被排除,以下是翻译好的内容:

原图:

Pillow 旋转不太正确

旋转 -90 度后的图像:

Pillow 旋转不太正确

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:

Pillow 旋转不太正确

Rotated -90:

Pillow 旋转不太正确

    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

huangapple
  • 本文由 发表于 2023年2月18日 15:04:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/75491742.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定