【问题标题】:Saved image using PIL but image doesn't open使用 PIL 保存图像但图像无法打开
【发布时间】:2019-12-17 17:24:31
【问题描述】:

我想要我的 python 脚本,所以将 python 窗口保存为 .JPG,它确实如此。但是当我尝试使用任何应用程序打开该 .jpg 时,它会告诉我文件类型不受支持。

当我将文件另存为 .eps 文件时,它会正确打开,但当我尝试另存为任何其他文件类型时,文件将无法打开。

win.postscript(file="image.jpg", colormode='color')

from PIL import Image as NewImage
img = NewImage.open("image.jpg")

【问题讨论】:

    标签: python image png python-imaging-library


    【解决方案1】:

    Tkinter 画布对象只能保存为 postscript 文件,实际上是 postscript 打印机语言文本文件。

    因此,如果您调用:

    win.postscript(file="image.jpg", colormode='color')
    

    它仍然会编写并创建一个 postscript 文件,这就是为什么当你用 .ps 重命名扩展名 [或简单地追加] 时它可以工作

    查看此博客以获得更好的实施:https://www.daniweb.com/programming/software-development/code/216929/saving-a-tkinter-canvas-drawing-python

    【讨论】:

      猜你喜欢
      • 2022-01-14
      • 1970-01-01
      • 1970-01-01
      • 2013-11-08
      • 1970-01-01
      • 2017-04-24
      • 2016-11-12
      • 2019-07-14
      • 1970-01-01
      相关资源
      最近更新 更多