@@ -148,14 +148,20 @@ def process(self, file: File, context: Optional[str]) -> Any:
148148 exif_dict = piexif .load (str (file .absolute_path ))
149149 for src in exif_dict .values ():
150150 if isinstance (src , dict ) and self .tag_id in src :
151- return self ._extract_value (src [self .tag_id ])
151+ return self ._extract_value (self . tag_type , src [self .tag_id ])
152152 else :
153153 raise MissingMetadataError ()
154154
155- def _extract_value (self , tag_value ):
156- if self .tag_type in (TAG_TYPES .Rational , TAG_TYPES .SRational ):
157- return round (tag_value [0 ] / tag_value [1 ], 1 )
158- if self .tag_type == TAG_TYPES .Ascii :
155+ def _extract_value (self , tag_type , tag_value ):
156+ if tag_type in (TAG_TYPES .Rational , TAG_TYPES .SRational ):
157+ if isinstance (tag_value [0 ], tuple ):
158+ return " " .join (str (self ._extract_value (v )) for v in tag_value )
159+ else :
160+ if tag_value [1 ] == 1 :
161+ return tag_value [0 ]
162+ else :
163+ return round (tag_value [0 ] / tag_value [1 ], 1 )
164+ if tag_type == TAG_TYPES .Ascii :
159165 return tag_value .decode ("ascii" )
160166 return tag_value
161167
@@ -187,3 +193,16 @@ def _generate_exif_tag_list() -> Iterator[str]:
187193
188194class ResolutionTagAlias (TagAlias ):
189195 """%Image.Width()x%Image.Height()"""
196+
197+
198+ class GpsPositionTag (ExifTag ):
199+ """Latitude and longitude of place where photo was taken"""
200+
201+ def configure (self ):
202+ self .latitude_tag_id , self .latitude_tag_type = self ._tag_name_to_id_type (
203+ "GpsLatitude"
204+ )
205+
206+
207+ class HasGpsPositionTagAlias (TagAlias ):
208+ """%Core.Not(){%Text.IsEmpty(){%Image.GpsPosition()}}"""
0 commit comments