image - Use BBOX Option In Percentage Instead Of Absolute Pixel - PyScreenShot Python -


the bbox option on grab() function of pyscreenshot able collect area of screen great.

is possible same using absolute percentage values? problem using pixel values on different monitors different resolution, grabbed image different.

so instead of saying

im = imagegrab.grab(bbox=(100,100,500,500)) 

i can same area, independently if screen 1920x1080 or other resolution

is looking for?

import mss # import mss.tools   mss.mss() sct:     monitor = sct.monitors[1]     left = monitor['left'] + monitor['width'] * 5 // 100  # 5% left     top = monitor['top'] + monitor['height'] * 5 // 100  # 5% top     right = left + 400  # 400px width     lower = top + 400  # 400px height     box = (left, top, right, lower)     im = sct.grab(box)     # mss.tools.to_png(im.rgb, im.size, 'screenshot.png') 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -