@@ -553,9 +553,10 @@ def _setitem(self, tag, value, legacy_api):
553553 )
554554 elif all (isinstance (v , float ) for v in values ):
555555 self .tagtype [tag ] = TiffTags .DOUBLE
556- else :
557- if all (isinstance (v , str ) for v in values ):
558- self .tagtype [tag ] = TiffTags .ASCII
556+ elif all (isinstance (v , str ) for v in values ):
557+ self .tagtype [tag ] = TiffTags .ASCII
558+ elif all (isinstance (v , bytes ) for v in values ):
559+ self .tagtype [tag ] = TiffTags .BYTE
559560
560561 if self .tagtype [tag ] == TiffTags .UNDEFINED :
561562 values = [
@@ -1548,16 +1549,17 @@ def _save(im, fp, filename):
15481549 # Custom items are supported for int, float, unicode, string and byte
15491550 # values. Other types and tuples require a tagtype.
15501551 if tag not in TiffTags .LIBTIFF_CORE :
1551- if (
1552- TiffTags .lookup (tag ).type == TiffTags .UNDEFINED
1553- or not Image .core .libtiff_support_custom_tags
1554- ):
1552+ if not Image .core .libtiff_support_custom_tags :
15551553 continue
15561554
15571555 if tag in ifd .tagtype :
15581556 types [tag ] = ifd .tagtype [tag ]
15591557 elif not (isinstance (value , (int , float , str , bytes ))):
15601558 continue
1559+ else :
1560+ type = TiffTags .lookup (tag ).type
1561+ if type :
1562+ types [tag ] = type
15611563 if tag not in atts and tag not in blocklist :
15621564 if isinstance (value , str ):
15631565 atts [tag ] = value .encode ("ascii" , "replace" ) + b"\0 "
0 commit comments