Skip to content

Commit

Permalink
check whether data is a bigtiff candidate to save execution time
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerzy Kowalski committed Jun 28, 2022
1 parent 0c1623d commit cd844a6
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions apeer_ometiff_library/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,8 @@ def write_ometiff(output_path, array, omexml_string = None, compression=None):
if omexml_string is None:
omexml_string = gen_xml(array)

try:
tifffile.imwrite(output_path, array, photometric = "minisblack", description=omexml_string, metadata=None,
compress=compression)
except struct.error:
tifffile.imwrite(output_path, array, photometric = "minisblack", description=omexml_string, metadata=None,
compress=compression, bigtiff=True)


data_limit_nbytes = 2 ** 32
tiff_metadata_nbytes = 2 ** 25
bigtiff = array.nbytes > data_limit_nbytes - tiff_metadata_nbytes
tifffile.imwrite(output_path, array, photometric="minisblack", description=omexml_string, metadata=None,
compress=compression, bigtiff=bigtiff)

0 comments on commit cd844a6

Please sign in to comment.