adding support for writing multipage tiffs
sofroniewn opened this issue · 9 comments
The current totif method only supports writing 2D arrays or 3D arrays where the third channel is color
It uses
from scipy.misc import imsave
Instead
from skimage.io import imsave
Supports writing 3D arrays to tiffs using tifffile
Unfortunately though this support is only for writing directly to files, not to file objects / byte streams and so I was unable to swap it out for the current imsave directly.
There is however a modified version of tifffile
here that supports writing to file objects
Using this version could allow for writing multipage tiffs
That would be a great feature, especially if totif()
can fully wrap the functionality of tifffile
(especially the compression
kwarg which allows lossless image compression).
@d-v-b cool good call, you could make those additions now in a separate PR just with the version of tifffile
we're using now, you just need to add the options in these two places:
happy to review a PR if you want to take a stab 😄
@freeman-lab I think I can whip a PR up in a few days implementing that.
@freeman-lab there is no version of tifffile
you're using now -- the current code for writing tifs uses scipy.misc.imsave
. So I don't think I can do a separate PR yet :)
Out of curiosity, why does thunder save images by writing to a bytestream?
@d-v-b oh my bad, i was thinking of reading tifs (which does use tifffile
). I can try to replace the basic tif writing with tifffile
and then you can add those features.
The bytestream writing is to support a standard interface between writing to a local / networked file system and writing to cloud storage like Amazon S3.
@freeman-lab @d-v-b Thunder uses the prebuilt version of tifffile
that is in scikit-image
. Unfortunately, that version doesn't allow writing to file objects or bytestreams -- it only allows you to pass it a filename. I looked at the code in scikit-image
though, and I think it should be doable to change it to allow the user to give a file object as well. I'm actually trying to see if I can put together a PR really quick making that work.
Oh awesome @jwittenbach !
A recent PR (#351) makes this the default behavior when writing 3D Images
objects to TIF