Image Magick++ close .display() Popup window by command

280 views Asked by At

in documentation of Magick++ I found the command to display an image

Image temp_image(my_image);temp_image.display(); // display 'my_image' in a pop-up window

this works quite well, but I can find a command to close this window by code.

My goal is to open a window with the image, give image new name by commandline input, then automatically close the window, and show next image to rename.

Although the new popup-window sets the "active window" to it's self. For entering some input to command line (e.g. new_name), I have to click again at the terminal window.

My (pseudo)code at the moment:

for(all_images){temp_image.display(); renaming_method();}

just now I have to close the upcoming window manualy by hand, better would be something like

for(all_images){temp_image.display(); renaming_method(); temp_image.display_close();}

do you have any ideas how to do this?

1

There are 1 answers

1
emcconville On BEST ANSWER

Magick++, and ImageMagick, doesn't have any methods to manage active display windows. You can roll your own XWindow method, but most projects I've seen just do the following routine...

  • Write temporary image
  • Ask OS to open temporary file by forking a process & calling xdg-open, open, or start commands (depending on OS).
  • Send SIGINT to pid when user wishes to close child process.
  • Clean-up any resources

Not ideal, but will get you roughly there.