mayavi
mayavi copied to clipboard
Retrieving the full path to an View screenshot image file
Hello, The Mayavi button in the interface allows one to dump the current view, with user-settable magnification, to an image file. How can my code retrieve the full path to the file the user selects to contain the dumped image, after that file has been saved?
I would really appreciate some guidance on this. Thanks in advance.
I am not entirely sure if you can retrieve the version that a user clicked, you could monkey patch the function the menu/toolbar item calls. Are you doing this with the "save" icon on the mayavi toolbar?
Yes. This issue is linked with #648 - if the machinery deep within TVTK can't handle image metadata, I will have to capture the path to the file saved, then use something like py3exiv2 to update the saved image file.
Hello, does anyone know how to capture this full file path yet?
Well if you use the UI and have closed the dialog, it is going to be hard to retrieve that information. What you can do is use savefig to do what you want or you can use mlab.screenshot to get ahold of the screenshot as an array and then do with that as you please.
Hi! So the sanest way to do this is to monkey patch the 'savefig' function (which then calls the individual format-specific save routines), within TVTK. For each image format in the if-else-if multiway branch then, the original version of that format's save routine would be called , followed by a format-specific write_metadata() routine provided by the user. It seems that Dublin Core metadata is easy to write into SVG files, but I imagine bitmap formats would be better off reusing PIL or Pillow routines.
Then I would create a UI button or 'Export' menu item in my Mayavi application that would allow selection of output format, output filename via a standard file/directory editor and an optional radio button 'Save metadata', before then calling mlab.savefig().
I would be very grateful for any example code you/others could contribute to help me understand how to do all this.
Is any built-in Dublin Core metadata support planned for TVTK/Mayavi savefig()?