confused
confused

Reputation: 1323

python how do I determine screen size

I need to resize an image. The original is 1024x768. My laptop screen is set to 1366x768. When I go to view the image the bottom is always cut off. I'm guessing it's because the image is 1024x768 but the image size doesn't take into account the box/window the image sits in, so the bottom of the image gets cuts off as a result.

What is the size, pixelwise, of the box/window and how do I determine the size of my screen, codewise, so I can reset the size of the image so the entire image will fit on the screen and none of it will get cut off. Or is there a way of having the image autoscale so it will fit the screen height resolution? I'm using PIL.

I know I can in the end just

new_image = old_image.resize(x, 768-box_height)

I just need to know the box height.

Upvotes: 0

Views: 3023

Answers (1)

roippi
roippi

Reputation: 25954

The most environment-agnostic way is likely to just ask tkinter:

import tkinter #python 3 syntax

root = tkinter.Tk()
root.withdraw()

width, height = root.winfo_screenwidth(), root.winfo_screenheight()

Upvotes: 2

Related Questions