vigra
vigra copied to clipboard
Python vigra: allow filenames or files in impex
The vigra numpy impex functions take filenames as parameters. Support "file or filename" to enable io for bytestreams.
This may be impossible if the underlying libraries (libtiff etc.) don't support it. Which file types would you like to support?
This is an interesting wish which came up before. Maybe it is related to issue #33 (tiled TIFF reading, but also ROI reading, 3D volume impex API etc.). We should list motivating use cases here I think.
+1 for this old issue, at least for TIFF and JPEG. When reading tiles from a remote server, it is nice to open in-memory image files without writing them to the hard disk first. For example, the Python requests
library docs provide an example of how to do this using PIL
:
>>> import requests
>>> r = requests.get('http://ukoethe.github.io/vigra/vigra_logo.gif')
>>> from PIL import Image
>>> from StringIO import StringIO
>>> i = Image.open(StringIO(r.content))
... on the other hand, I'm using PIL
for now, and it seems to work just fine for my needs.