question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

combined monitor image and mss().monitors incorrect

See original GitHub issue

General information:

  • OS name: Windows 10
  • OS version: 10.0.17134.523
  • OS architecture: x64
  • Resolutions:
    • Monitor 1: 1600x900
    • Monitor 2: 1920x1080
  • Python version: 3.7.0
  • MSS version: 4.0.1

The combined monitor image is rendering incorrectly and (because?) the monitors property returns invalid results.

If you look at my output from print(sct.monitors) you will see the results are impossible:

[{'left': 0, 'top': -172, 'width': 3520, 'height': 1252}, {'left': 0, 'top': 0, 'width': 1600, 'height': 900}, {'left': 1600, 'top': -172, 'width': 1920, 'height': 1080}]

If I understand correctly, this output is saying that monitor 2 lies outside of the combination of all monitors together, which of course is impossible. I think this is what causes the 172-pixel black bar along the bottom of the image.

fullscreen

I think the correct output of mss().monitors should be:

[{'left': 0, 'top': 0, 'width': 3520, 'height': 1080}, {'left': 0, 'top': 172, 'width': 1600, 'height': 900}, {'left': 1600, 'top': 0, 'width': 1920, 'height': 1080}]

here is a screenshot of my monitor position in windows display manager:

image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
SergeyKalutskycommented, Mar 14, 2019

If I’ll have some time I will work on a fix. Shouldn’t be hard to do.

1reaction
grintorcommented, Feb 25, 2019

I was right. I was able to work around the windows bug like this:

import mss
from PIL import Image

sct = mss.mss()

all_mon = sct.monitors[0]
size = (all_mon['width'], (all_mon['height']))
img = Image.new('RGB', size)

for num, monitor in enumerate(sct.monitors[1:], 1):
	sct_img = sct.grab(monitor)

	monitor_img = Image.frombytes("RGB", sct_img.size, sct_img.bgra, "raw", "BGRX")
	
	position = (monitor['left'], monitor['top'])
	
	img.paste(monitor_img, position)

img.show()
Read more comments on GitHub >

github_iconTop Results From Across the Web

Question about MSS() and monitor selection : r/learnpython
I'm looking to get a screenshot of the primary monitor without passing dimensions as the resolution may change from machine to machine.
Read more >
Monitors incorrectly identified - Microsoft Community
Hi, I have two monitors, a Dell and an Asus. The Dell is connected via HDMI while the Asus uses Display Port. The...
Read more >
Recording full screen at lower resolution (mss) - Stack Overflow
I have this example code down below that uses the "mss" library to take screenshots of the monitor and display that in a...
Read more >
Panel moves to wrong screen when external monitor is ...
Can confirm this issue, when resuming the panel from the bottom of "Laptop Screen" moves to the bottom of one of the two...
Read more >
Multi-monitor only appearing on ONE monitor? - ED Forums
Biggest problem was I could no longer see the "apply" button ... I don't think you can display both in cockpit and and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found