【问题标题】:python:on linux os how to save clipboard as imagepython:在linux os上如何将剪贴板保存为图像
【发布时间】:2021-05-17 15:25:34
【问题描述】:

我想将剪贴板图片内容转换成图片

我试过了

from PIL import ImageGrab
im = ImageGrab.grabclipboard()
im.save(filename)

上面写着ImageGrab.grabclipboard() is macOS and Windows only

【问题讨论】:

标签: python-3.x linux python-imaging-library


【解决方案1】:

目前我必须使用 xclip 来解决这个问题

它会尝试从剪贴板保存图像,如果没有,它会返回 1

    import os
    if os.system(f"xclip -selection clipboard -target image/png -out > {filename}") == 0:
        print("save")
        return 0
    else:
        return 1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-21
    • 1970-01-01
    • 1970-01-01
    • 2011-10-14
    • 1970-01-01
    • 2020-05-05
    相关资源
    最近更新 更多