Skip to content

Commit efafa14

Browse files
Omit compression method/ratio from metadata map if not defined
1 parent bd41c24 commit efafa14

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

isyntax2raw/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ def get_image_metadata_sdk_v2(self, image_no):
281281
view = self.get_view(img)
282282
image_scale_factor = view.scale
283283

284+
# compression method and ratio are informational only
285+
# these values are not needed for decompression
286+
# and may be missing for label/macro images in particular
284287
compression_method = None
285288
try:
286289
compression_method = img.lossy_image_compression_method
@@ -296,10 +299,6 @@ def get_image_metadata_sdk_v2(self, image_no):
296299
image_metadata = {
297300
"Image type":
298301
image_type,
299-
"Lossy image compression method":
300-
compression_method,
301-
"Lossy image compression ratio":
302-
compression_ratio,
303302
"Image dimension names":
304303
view.dimension_names,
305304
"Image dimension types":
@@ -313,6 +312,13 @@ def get_image_metadata_sdk_v2(self, image_no):
313312
"Block size":
314313
img.block_size(),
315314
}
315+
if compression_method is not None:
316+
image_metadata[
317+
"Lossy image compression method"] = compression_method
318+
319+
if compression_ratio is not None:
320+
image_metadata["Lossy image compression ratio"] = compression_ratio
321+
316322
if image_type == "WSI":
317323
image_metadata["Color space transform"] = \
318324
img.colorspace_transform

0 commit comments

Comments
 (0)