[英]Why i'm getting an error while saving images in python using Pillow?
hi everyone I'm trying to save images in python, using PIL, but when I run my gui application and when I save them an error occurs, the images are saved but not like an image.大家好,我正在尝试使用 PIL 将图像保存在 python 中,但是当我运行我的 gui 应用程序并保存它们时发生错误,图像被保存但不像图像。 When I open them, they look like a text file...当我打开它们时,它们看起来像一个文本文件......
This is the code I'm using:这是我正在使用的代码:
def save_all(images):
count = 1
for i in images:
i.save("image" + str(count) + ".png", format="png")
count += 1
I suspect it's because the format is wrong - try:我怀疑这是因为格式错误 - 尝试:
def save_all(images):
count = 1
for i in images:
i.save(f"image{count}.{i.format}", format=i.format)
count += 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.