diff --git a/pyproject.toml b/pyproject.toml index b14fb3e..f24c6ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "tiffwrite" -version = "2024.3.0" +version = "2024.4.0" description = "Parallel tiff writer compatible with ImageJ." authors = ["Wim Pomp, Lenstra lab NKI "] license = "GPL-3.0-or-later" diff --git a/tiffwrite/__init__.py b/tiffwrite/__init__.py index 0e04d26..f2dfcff 100755 --- a/tiffwrite/__init__.py +++ b/tiffwrite/__init__.py @@ -452,7 +452,7 @@ class IJTiffFile: desc_bytes.append(self.comment) else: desc_bytes.append(bytes(self.comment, 'ascii')) - return b'\n'.join(desc_bytes) + return b'\n'.join(desc_bytes) + b'\0' @cached_property def colormap_bytes(self) -> Optional[bytes]: @@ -485,13 +485,14 @@ class IJTiffFile: for n, tags in self.frame_extra_tags.items(): framenr, channel = self.get_frame_number(n) 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][262] = Tag('SHORT', 3) if self.colors is not None: for c, color in enumerate(self.colors_bytes): - ifds[c][320] = Tag('SHORT', color) - ifds[c][262] = Tag('SHORT', 3) + if c in ifds: + ifds[c][320] = Tag('SHORT', color) + ifds[c][262] = Tag('SHORT', 3) if 0 in ifds and 306 not in ifds[0]: ifds[0][306] = Tag('ASCII', datetime.now().strftime('%Y:%m:%d %H:%M:%S')) wrn = False @@ -518,7 +519,7 @@ class IJTiffFile: wrn = True if wrn: 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: return self