【发布时间】:2015-07-01 19:48:54
【问题描述】:
我阅读了一张图片并将其显示在 Canvas 中:
im=the_canvas.create_image(0,0,anchor="nw",image=img)
然后,我保存它:
returned_value=the_canvas.postscript(file="saved.ps", height=image_h, width=image_w, colormode="color")
r=Image.open("saved.ps")
r.save("saved.png")
如何将图像保存为 png 或 jpg 格式而不降低其质量? 提前谢谢你。
【问题讨论】:
-
遗憾的是,Tkinter 画布除了 postscript 之外没有其他格式可以原生保存。您是否尝试通过画布上的绘图功能保存对图像所做的修改?我的建议是使用 Python Imaging Library 函数。无论您在画布上做什么,都可以在幕后使用 PIL 的函数在图像副本上执行相同的操作。
-
@Brionius 好的,谢谢您提供的信息。那我得学习一下PIL了。
标签: python image canvas tkinter python-imaging-library