Any chance to display an image?
Like popup quick view window for an image in memory, rather than saving it to disk before programmatically open it via "Preview" app. Is that possible now? Or would you consider implementing this feature?
You can do this by using StringIO for the file contents. I do this to generate QR Codes that pop-up in preview. I've made a PR to add this functionality #89
I took a look at your PR, and it seems to be previewing an image on disk. I was initially thinking about directly previewing an image in memory, like by directly transforming an BytesIO content into an NSImage instance without writing the file to disk.
Oh, I see. If you submit a Pull Request with the changes I'd be happy to review it.
Actually that's the problem: I cannot show the image. First I tried your code in #89, and got this error:
2018-12-01 11:43:28.040 Python[42369:18111772] Traceback (most recent call last):
File "/Users/joker/Works/rumps/rumps/rumps.py", line 1035, in callback_
return _call_as_function_or_method(callback, self)
File "/Users/joker/Works/rumps/rumps/rumps.py", line 384, in _call_as_function_or_method
return method(event)
File "simple.py", line 20, in sayhi
rumps.show_image('/Users/joker/Downloads/256.png')
File "/Users/joker/Works/rumps/rumps/rumps.py", line 212, in show_image
return _nsimage_window_from_file(image)
File "/Users/joker/Works/rumps/rumps/rumps.py", line 277, in _nsimage_window_from_file
window = NSImageView.alloc().init(image)
TypeError: Need 0 arguments, got 1
I worked around by using this instead of NSImageView.alloc().init(image):
window = NSImageView.alloc().init()
window.setImage_(image)
This time I got no error, but the image did not show up either.
Now that I know how to converting raw bytes into an NSImage instance, it would be nice if I could be able to test it.
data = NSData.dataWithBytes_length_(raw_bytes, len(raw_bytes))
image = NSImage.alloc().initWithData_(data)
/Users/joker
