如何在Python中制作高质量的截图

时间:2018-01-19 00:06:38

标签: python screenshot resolution

我有这个Python功能,它可以很好地拍摄常规截图。

我希望能够以高分辨率拍摄截图。是否可以修改此代码以实现此目的,还是需要与其他库集成?

def SaveScreen(self):
    print "save screen"

    # SCREENSHOT_CWDSAVE
    if SCREENSHOT_CWDSAVE:
        if not os.path.exists(os.getcwd()+os.sep+"screenshot"):
            os.mkdir(os.getcwd()+os.sep+"screenshot")

        (succeeded, name) = grp.SaveScreenShotToPath(os.getcwd()+os.sep+"screenshot"+os.sep)
    elif SCREENSHOT_DIR:
        (succeeded, name) = grp.SaveScreenShot(SCREENSHOT_DIR)
    else:
        (succeeded, name) = grp.SaveScreenShot()
    # END_OF_SCREENSHOT_CWDSAVE

    if succeeded:
        pass
        """
        chat.AppendChat(chat.CHAT_TYPE_INFO, name + localeInfo.SCREENSHOT_SAVE1)
        chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SCREENSHOT_SAVE2)
        """
    else:
        chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SCREENSHOT_SAVE_FAILURE)

1 个答案:

答案 0 :(得分:0)

2种解决方案:您可以尝试其他模块,例如MSS(简单,高效并创建高质量的PNG图片),您可以更改函数代码SaveJPEG

// https://pastebin.com/xAv30gK1 at line 169
return jpeg_save(pbyBuffer, uWidth, uHeight, 85, pszFileName) != 0;

你看到85了吗?这是图片质量。只需更改为100;)