- compression option
- comment option
This commit is contained in:
2
setup.py
2
setup.py
@@ -5,7 +5,7 @@ with open('README.md', 'r') as fh:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name='tiffwrite',
|
name='tiffwrite',
|
||||||
version='2022.6.0',
|
version='2022.10.0',
|
||||||
author='Wim Pomp @ Lenstra lab NKI',
|
author='Wim Pomp @ Lenstra lab NKI',
|
||||||
author_email='w.pomp@nki.nl',
|
author_email='w.pomp@nki.nl',
|
||||||
description='Parallel tiff writer compatible with ImageJ.',
|
description='Parallel tiff writer compatible with ImageJ.',
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ class IJTiffFile:
|
|||||||
wp@tl20200214
|
wp@tl20200214
|
||||||
"""
|
"""
|
||||||
def __init__(self, path, shape, dtype='uint16', colors=None, colormap=None, pxsize=None, deltaz=None,
|
def __init__(self, path, shape, dtype='uint16', colors=None, colormap=None, pxsize=None, deltaz=None,
|
||||||
timeinterval=None, **extratags):
|
timeinterval=None, compression=(8, 9), comment=None, **extratags):
|
||||||
assert len(shape) >= 3, 'please specify all c, z, t for the shape'
|
assert len(shape) >= 3, 'please specify all c, z, t for the shape'
|
||||||
assert len(shape) <= 3, 'please specify only c, z, t for the shape'
|
assert len(shape) <= 3, 'please specify only c, z, t for the shape'
|
||||||
assert np.dtype(dtype).char in 'BbHhf', 'datatype not supported'
|
assert np.dtype(dtype).char in 'BbHhf', 'datatype not supported'
|
||||||
@@ -345,6 +345,8 @@ class IJTiffFile:
|
|||||||
self.pxsize = pxsize
|
self.pxsize = pxsize
|
||||||
self.deltaz = deltaz
|
self.deltaz = deltaz
|
||||||
self.timeinterval = timeinterval
|
self.timeinterval = timeinterval
|
||||||
|
self.compression = compression
|
||||||
|
self.comment = comment
|
||||||
self.extratags = {} if extratags is None else Tag.to_tags(extratags)
|
self.extratags = {} if extratags is None else Tag.to_tags(extratags)
|
||||||
if pxsize is not None:
|
if pxsize is not None:
|
||||||
pxsize = Tag.fraction(pxsize)
|
pxsize = Tag.fraction(pxsize)
|
||||||
@@ -381,7 +383,7 @@ class IJTiffFile:
|
|||||||
with BytesIO() as framedata:
|
with BytesIO() as framedata:
|
||||||
with tifffile.TiffWriter(framedata, bigtiff=self.header.bigtiff, byteorder=self.header.byteorder) as t:
|
with tifffile.TiffWriter(framedata, bigtiff=self.header.bigtiff, byteorder=self.header.byteorder) as t:
|
||||||
# predictor=True might save a few bytes, but requires the package imagecodes to save floats
|
# predictor=True might save a few bytes, but requires the package imagecodes to save floats
|
||||||
t.write(frame, compression=(8, 9), contiguous=True, predictor=False)
|
t.write(frame, compression=self.compression, contiguous=True, predictor=False)
|
||||||
return framedata.getvalue()
|
return framedata.getvalue()
|
||||||
|
|
||||||
def save(self, frame, c, z, t, **extratags):
|
def save(self, frame, c, z, t, **extratags):
|
||||||
@@ -450,7 +452,14 @@ class IJTiffFile:
|
|||||||
desc.append(f'spacing={self.deltaz}')
|
desc.append(f'spacing={self.deltaz}')
|
||||||
if self.timeinterval is not None:
|
if self.timeinterval is not None:
|
||||||
desc.append(f'finterval={self.timeinterval}')
|
desc.append(f'finterval={self.timeinterval}')
|
||||||
return bytes('\n'.join(desc), 'ascii')
|
desc = [bytes(d, 'ascii') for d in desc]
|
||||||
|
if self.comment is not None:
|
||||||
|
desc.append(b'')
|
||||||
|
if isinstance(self.comment, bytes):
|
||||||
|
desc.append(self.comment)
|
||||||
|
else:
|
||||||
|
desc.append(bytes(self.comment, 'ascii'))
|
||||||
|
return b'\n'.join(desc)
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def empty_frame(self):
|
def empty_frame(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user