Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding support for writing multipage tiffs #277

Closed
sofroniewn opened this issue Apr 12, 2016 · 9 comments
Closed

adding support for writing multipage tiffs #277

sofroniewn opened this issue Apr 12, 2016 · 9 comments

Comments

@sofroniewn
Copy link

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

@d-v-b
Copy link
Contributor

d-v-b commented Apr 15, 2016

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).

@freeman-lab
Copy link
Member

@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:

@freeman-lab
Copy link
Member

happy to review a PR if you want to take a stab 😄

@d-v-b
Copy link
Contributor

d-v-b commented Apr 15, 2016

@freeman-lab I think I can whip a PR up in a few days implementing that.

@d-v-b
Copy link
Contributor

d-v-b commented Apr 16, 2016

@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?

@freeman-lab
Copy link
Member

@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.

@jwittenbach
Copy link
Contributor

@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.

@freeman-lab
Copy link
Member

Oh awesome @jwittenbach !

@jwittenbach
Copy link
Contributor

A recent PR (#351) makes this the default behavior when writing 3D Images objects to TIF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants