File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed
Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -527,8 +527,7 @@ def generate_blob(self): # noqa: PLR0915
527527 self .height = img .height
528528 self .width = img .width
529529
530- is_rcm = not self .is_color (img )
531-
530+ is_rcm = img .mode .startswith ("I;16" )
532531 if is_rcm :
533532 self .is_cog = self .meets_cog_threshold (img )
534533 if self .is_cog :
@@ -542,6 +541,8 @@ def generate_blob(self): # noqa: PLR0915
542541 else :
543542 if self .meets_cog_threshold (img ):
544543 raise InvalidBlobError ("Blob is too large to be stored." ) # noqa: TRY301
544+ if not img .mode .startswith ("RGB" ):
545+ raise InvalidBlobError ("Blob has non-RGB mode." ) # noqa: TRY301
545546 self .is_cog = False
546547 converter = self ._convert_blob_to_rgb
547548 converted_blob_type = "image/jpeg"
@@ -843,10 +844,6 @@ def metadata_keys():
843844 field .name for field in Accession ._meta .fields if hasattr (AccessionMetadata , field .name )
844845 ]
845846
846- @staticmethod
847- def is_color (img : PIL .Image .Image ) -> bool :
848- return img .mode in {"RGB" , "RGBA" }
849-
850847 @staticmethod
851848 def meets_cog_threshold (img : PIL .Image .Image ) -> bool :
852849 return img .height * img .width > IMAGE_COG_THRESHOLD
You can’t perform that action at this time.
0 commit comments