Created
May 28, 2024 09:22
-
-
Save ArthurDelannoyazerty/83b59aba51deb70e4679b025443d5767 to your computer and use it in GitHub Desktop.
Python functions that return the dpi of the main screen, and the x/y size of the image in inch in order to resize the plot automatically.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ctypes | |
import tkinter | |
def get_dpi(): | |
ctypes.windll.shcore.SetProcessDpiAwareness(1) | |
root = tkinter.Tk() | |
dpi = ctypes.windll.user32.GetDpiForWindow(root.winfo_id()) | |
root.destroy() | |
return dpi | |
def get_inches_plot(array): | |
dpi = get_dpi() | |
return array.shape[1]/dpi, array.shape[0]/dpi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example
quality
is the detail of the image