It works! Many thanks!
I know it's a little off-topic, but I thought it's better to ask here than making a new thread. Is it possible to resize the window in a script? Because the image isn't the same size everytime so I need to resize the window dependent on the size of the image.