简体   繁体   English

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

[英]How to make a high quality screenshot in Python

I have this Python function and it works well taking a regular screenshot. 我具有此Python函数,并且可以正常拍摄常规屏幕截图。

I would like to be able to take the screenshot in high resolution. 我希望能够以高分辨率拍摄屏幕截图。 Could this code be modified to accomplish this, or would I need to integrate with another library? 可以修改此代码来完成此操作,还是需要与另一个库集成?

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)

2 solutions for you: either you try another module like MSS (easy, efficient and creates high quality PNG pictures), either you change the code of the function SaveJPEG : 为您提供2种解决方案:您尝试使用另一个模块(例如MSS) (简单,高效并创建高质量PNG图片),或者更改功能SaveJPEG的代码:

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

You see the 85 ? 您看到85吗? It is the picture quality. 这是画质。 Just change to 100 ;) 只需更改为100 ;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Windows 7中使用python制作屏幕截图? - How to make a screenshot in Windows 7 with python? 如何高质量录制屏幕 - how to record screen in high quality 如何在 iOS 的 appium webdriver 中提高屏幕截图质量? - How to increase screenshot quality in the appium webdriver for IOS? 是否可以使用 Python 将低质量图像转换为高质量图像? - Is it possible to turn a low quality image into a high quality one with Python? 以非常高的质量在 Python 中保存图像 - Saving images in Python at a very high quality 如何编写python opencv脚本,用高品质视频替换低品质视频,使音频与新视频同步? - How do I write a python opencv script for replacing a low quality video with a high quality video such that the audio syncs with new video? 如何制作高质量的 matplotlib 动画并避免模糊的文本/线条渲染? - How can I make high-quality matplotlib animations and avoid blurry text/line rendering? 如何在Linux中编程截图(高fps)(编程) - How to take screenshot (high fps) in Linux (programming) "如何以高分辨率捕获网站截图?" - How to capture website screenshot in high resolution? 如何使日期和时间成为python截取的屏幕截图的名称? - How can I make the date and time the name of a screenshot taken by python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM