Alexis Cllmb
Alexis Cllmb

Reputation: 107

Python write / add image data by appending to Multipage TIFF file using tifffile

I would like to add image data (a numpy matrix) to an already existing Multipage TIFF file using the tifffile module from Christoph Gohlke: http://www.lfd.uci.edu/~gohlke/code/tifffile.py.html

And I would like to do it without having to load the whole file because it can be a heavy one (long fluorescence microscopy experiments...). On this page: https://github.com/scienceopen/pyimagevideo/blob/master/Demo_image_write_multipage.py line 68 they say it is possible, but they just say "read the code", and I couldn't figure out how to append images doing so. I tried

tifffile.save(ImagePath, ImageData) and

with tifffile.TiffWriter(ImagePath) as tif2write:
    tif2write.save(ImageData)

but I doesn't append data, it overwrites the file.

Upvotes: 3

Views: 2646

Answers (1)

Alexis Cllmb
Alexis Cllmb

Reputation: 107

I finally wrote to Christoph Gohlke and indeed he said that his module couldn't append a new image to a TIFF file. So he modified his module and now we can append as many images desired to an already existing file! Check on his website http://www.lfd.uci.edu/~gohlke/code/tifffile.py.html, the version that couldn't do it was the Revision 2016.10.28, so if on his website you find a newer "Revision" it should work, in the meantime... be patient ;)

Upvotes: 2

Related Questions