1+ from __future__ import annotations
2+
13import abc
24import datetime
35import io
@@ -477,9 +479,9 @@ def extract_orientation(self) -> int:
477479
478480 def _extract_alternative_fields (
479481 self ,
480- fields : T .Sequence [str ],
481- field_type : T . Type [_FIELD_TYPE ],
482- ) -> T . Optional [ _FIELD_TYPE ] :
482+ fields : T .Iterable [str ],
483+ field_type : type [_FIELD_TYPE ],
484+ ) -> _FIELD_TYPE | None :
483485 """
484486 Extract a value for a list of ordered fields.
485487 Return the value of the first existed field in the list
@@ -736,17 +738,7 @@ def extract_direction(self) -> T.Optional[float]:
736738 "GPS GPSImgDirection" ,
737739 "GPS GPSTrack" ,
738740 ]
739- direction = self ._extract_alternative_fields (fields , float )
740- if direction is not None :
741- if direction > 360 :
742- # fix negative value wrongly parsed in exifread
743- # -360 degree -> 4294966935 when converting from hex
744- bearing1 = bin (int (direction ))[2 :]
745- bearing2 = "" .join ([str (int (int (a ) == 0 )) for a in bearing1 ])
746- direction = - float (int (bearing2 , 2 ))
747- direction %= 360
748-
749- return direction
741+ return self ._extract_alternative_fields (fields , float )
750742
751743 def extract_lon_lat (self ) -> T .Optional [T .Tuple [float , float ]]:
752744 lat_tag = self .tags .get ("GPS GPSLatitude" )
@@ -774,7 +766,9 @@ def extract_make(self) -> T.Optional[str]:
774766 """
775767 Extract camera make
776768 """
777- make = self ._extract_alternative_fields (["Image Make" , "EXIF LensMake" ], str )
769+ make = self ._extract_alternative_fields (
770+ ["Image Make" , "EXIF Make" , "EXIF LensMake" ], str
771+ )
778772 if make is None :
779773 return None
780774 return make .strip ()
@@ -783,7 +777,9 @@ def extract_model(self) -> T.Optional[str]:
783777 """
784778 Extract camera model
785779 """
786- model = self ._extract_alternative_fields (["Image Model" , "EXIF LensModel" ], str )
780+ model = self ._extract_alternative_fields (
781+ ["Image Model" , "EXIF Model" , "EXIF LensModel" ], str
782+ )
787783 if model is None :
788784 return None
789785 return model .strip ()
@@ -818,8 +814,8 @@ def extract_orientation(self) -> int:
818814 def _extract_alternative_fields (
819815 self ,
820816 fields : T .Sequence [str ],
821- field_type : T . Type [_FIELD_TYPE ],
822- ) -> T . Optional [ _FIELD_TYPE ] :
817+ field_type : type [_FIELD_TYPE ],
818+ ) -> _FIELD_TYPE | None :
823819 """
824820 Extract a value for a list of ordered fields.
825821 Return the value of the first existed field in the list
0 commit comments