I’m using Python and the library
opencv-python) to display an image in a window but my image is super big and going off the screen. How do I resize my window so the image stays on the screen without distorting it?
Here’s an example:
window_width = 600 window_height = 600 cv2.namedWindow("my_window_name", cv2.WINDOW_NORMAL) cv2.resizeWindow("my_window_name", window_width, window_height) cv2.imshow("my_window_name", image_to_show)
Basically we’re creating a
namedWindow which allows us to identify and modify that window later. We then mutate it with
resizeWindow and show our image in it with
I regularly post about tech topics I run into. You can get a periodic email containing updates on new posts and things I’ve built by subscribing here.
Hi I'm Hamilton and I wrote / built this! I like doing lots of things, but mostly I like to build (and then share those buildings). Some things I'm currently building: art, software, and prose. To stay up-to-date with my latest buildings, subscribe to my email list or follow one of my many other accounts. #buildit #shipit #justhamit