- add null byte add end of description
- do not raise Exception when frame 0 was not added so that the external error causing it can be debugged
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "tiffwrite"
|
name = "tiffwrite"
|
||||||
version = "2024.3.0"
|
version = "2024.4.0"
|
||||||
description = "Parallel tiff writer compatible with ImageJ."
|
description = "Parallel tiff writer compatible with ImageJ."
|
||||||
authors = ["Wim Pomp, Lenstra lab NKI <w.pomp@nki.nl>"]
|
authors = ["Wim Pomp, Lenstra lab NKI <w.pomp@nki.nl>"]
|
||||||
license = "GPL-3.0-or-later"
|
license = "GPL-3.0-or-later"
|
||||||
|
|||||||
@@ -452,7 +452,7 @@ class IJTiffFile:
|
|||||||
desc_bytes.append(self.comment)
|
desc_bytes.append(self.comment)
|
||||||
else:
|
else:
|
||||||
desc_bytes.append(bytes(self.comment, 'ascii'))
|
desc_bytes.append(bytes(self.comment, 'ascii'))
|
||||||
return b'\n'.join(desc_bytes)
|
return b'\n'.join(desc_bytes) + b'\0'
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def colormap_bytes(self) -> Optional[bytes]:
|
def colormap_bytes(self) -> Optional[bytes]:
|
||||||
@@ -485,13 +485,14 @@ class IJTiffFile:
|
|||||||
for n, tags in self.frame_extra_tags.items():
|
for n, tags in self.frame_extra_tags.items():
|
||||||
framenr, channel = self.get_frame_number(n)
|
framenr, channel = self.get_frame_number(n)
|
||||||
ifds[framenr].update(tags)
|
ifds[framenr].update(tags)
|
||||||
if self.colormap is not None:
|
if 0 in ifds and self.colormap is not None:
|
||||||
ifds[0][320] = Tag('SHORT', self.colormap_bytes)
|
ifds[0][320] = Tag('SHORT', self.colormap_bytes)
|
||||||
ifds[0][262] = Tag('SHORT', 3)
|
ifds[0][262] = Tag('SHORT', 3)
|
||||||
if self.colors is not None:
|
if self.colors is not None:
|
||||||
for c, color in enumerate(self.colors_bytes):
|
for c, color in enumerate(self.colors_bytes):
|
||||||
ifds[c][320] = Tag('SHORT', color)
|
if c in ifds:
|
||||||
ifds[c][262] = Tag('SHORT', 3)
|
ifds[c][320] = Tag('SHORT', color)
|
||||||
|
ifds[c][262] = Tag('SHORT', 3)
|
||||||
if 0 in ifds and 306 not in ifds[0]:
|
if 0 in ifds and 306 not in ifds[0]:
|
||||||
ifds[0][306] = Tag('ASCII', datetime.now().strftime('%Y:%m:%d %H:%M:%S'))
|
ifds[0][306] = Tag('ASCII', datetime.now().strftime('%Y:%m:%d %H:%M:%S'))
|
||||||
wrn = False
|
wrn = False
|
||||||
@@ -518,7 +519,7 @@ class IJTiffFile:
|
|||||||
wrn = True
|
wrn = True
|
||||||
if wrn:
|
if wrn:
|
||||||
warnings.warn('Some frames were not added to the tif file, either you forgot them, '
|
warnings.warn('Some frames were not added to the tif file, either you forgot them, '
|
||||||
'or an error occured and the tif file was closed prematurely.')
|
'or an error occurred and the tif file was closed prematurely.')
|
||||||
|
|
||||||
def __enter__(self) -> IJTiffFile:
|
def __enter__(self) -> IJTiffFile:
|
||||||
return self
|
return self
|
||||||
|
|||||||
Reference in New Issue
Block a user