I'm trying to get the physical size of the monitor. I'm able to get the resolution and I want to find the DPI of the screen. Is there any simple way in Python for this?
Machine: Raspberry Pi
Code for finding resolution:
import subprocess
def get_dpi:
#...code for finding dpi
return dpi
output = subprocess.Popen('xrandr | grep "\*" | cut -d" " -f4',shell=True, stdout=subprocess.PIPE).communicate()[0]
resolution = output.split()[0].split(b'x')
screenWidth = int(resolution[0].decode('utf-8'))
screenHeight = int(resolution[1].decode('utf-8'))
screenDpi = get_dpi()
#print(screenWidth,screenDpi)
# get actual screen width and height in inches
physicalWidth = screenWidth/screenDpi
physicalHeight = physicalHeight/screenDpi
print(physicalWidth, physicalHeight)