Write single image series in append mode
See original GitHub issueHi @cgohlke
Thanks for the awesome package 😃
I’m trying to write chunks of a video to tiff using the append mode (append=True
). When I load the tiff file I get the right number of pages, but if I try to memmap it I only get one chunk at a time. In fact, each imsave
call appends a new series to the tiff file.
Is it possible to write in append mode and extend the existing series, so that in the end I can memmap the entire video?
Minimal example:
import numpy as np
import tifffile
save_path = 'test_append.tif'
# create 1000 frmes, 50x50 image size
video = np.random.randn(1000, 50, 50)
# write 100 frames at a time:
len_chunk = 100
for i in range(10):
tifffile.imsave(save_path, video[i * len_chunk:(i+1) * len_chunk], append=True)
tif = tifffile.TiffFile(save_path)
print(len(tif.pages)) # correctly prints 10000
tif.close()
video0 = tifffile.memmap(save_path, series=0)
print(video0.shape) # prints (100, 50, 50)
video1 = tifffile.memmap(save_path, series=1)
print(video1.shape) # prints (100, 50, 50)
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
pandas.Series.append — pandas 1.5.2 documentation
General function to concatenate DataFrame or Series objects. Notes. Iteratively appending to a Series can be more computationally intensive than a single ......
Read more >Python append to a file - GeeksforGeeks
Append and Read ('a+'): Open the file for reading and writing. When the file is opened in append mode in Python, the handle...
Read more >Python Write to File – Open, Read, Append, and Other File ...
The "a" mode allows you to open a file to append some content to it. And we want to add a new line...
Read more >MATLAB imwrite - Write image to graphics file - MathWorks
Draw a series of plots, capture them as images, and write them into one animated GIF ... In "append" mode, imwrite adds a...
Read more >Python Program to Append to a File - Programiz
Open the file in append 'a' mode, and write to it using write() method. Inside write() method, a string "new text" is passed....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you don’t need the tifffile metadata, try:
Otherwise provide a generator of frames (not tested):
The first solution did the trick 😃
Thanks!