2024-05-23 18:17:20 发布
网友
我参与了一个项目,在这个项目中,人们必须看着镜子反射的屏幕进行互动。图像是反转的,所以我想用python创建一个程序来解决这个问题。我不知道从哪里开始,因为我刚接触过树莓皮和树莓果。你知道吗
1)X.Org
如果您想翻转X Window System(X.Org)显示的所有内容,可以使用xrandr命令。你知道吗
xrandr
xrandr -y将镜像显示(垂直翻转图像)。xrandr -o normal将把显示返回到默认值。你知道吗
xrandr -y
xrandr -o normal
2)Python
如果用Python编写的程序将显示一些图像,并且希望在程序中翻转这些图像,那么可以使用Pillow模块。你知道吗
下面是一个片段,它垂直反转名为cat.jpg的图像并将其保存到vertical_flip_cat.jpg:
cat.jpg
vertical_flip_cat.jpg
from PIL import Image my_image = Image.open('cat.jpg') my_image.transpose(Image.FLIP_TOP_BOTTOM).save('vertical_flip_cat.jpg')
Here is an overview of the Pillow module with examples.
1)X.Org
如果您想翻转X Window System(X.Org)显示的所有内容,可以使用
xrandr
命令。你知道吗xrandr -y
将镜像显示(垂直翻转图像)。xrandr -o normal
将把显示返回到默认值。你知道吗2)Python
如果用Python编写的程序将显示一些图像,并且希望在程序中翻转这些图像,那么可以使用Pillow模块。你知道吗
下面是一个片段,它垂直反转名为
cat.jpg
的图像并将其保存到vertical_flip_cat.jpg
:Here is an overview of the Pillow module with examples.
相关问题 更多 >
编程相关推荐