pythonscreenshotpython-mss

Python MSS - make screenshot filesize smaller or in jpg?


Depending on what is shown on the monitor, the screenshot of Python MSS can go up to 2 MB even though I have the compression set to the maximum which is 9. Is there another way to reduce the filesize or to save it instead as a jpg which would be even more compressed? Quality doesn't much matter and I'd rather not have to use PIL.

from mss import mss

with mss() as sct:
    sct.compression_level = 9
    sct.shot(mon=-1, output="C:\test\test.png")

Solution

  • As of now MSS includes only a basic PNG compressor. Even if we implemented more complex filters in the PNG format, it may be still heavy.

    The screenshot size depends heavily on the screen size.

    An idea would be to include a JPG compressor, in pure Python, but I do not have the time for that, so pull requests are always welcome. What module can you use? Because you can play with pixels and pass them to another module perhaps?