Python Forum
can not get gps information returning only integer
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
can not get gps information returning only integer
#1
I tried following code to read GPS ifnormation from jpeg file but it is only printing out single integer i.e. 739.
But when I open the file property in Windows, I see lot more data (i.e. Latitude, Longitude, Altitude), what is wrong???

#Import GPSTAGS
#from PIL.ExifTags import GPSTAGS
#print(GPSTAGS)

from PIL import Image
from PIL.ExifTags import TAGS

# Open Image
img=Image.open('DJI_0001.JPG')

#Get EXIF Data

exif_table={}
for k, v in img.getexif().items():
    tag=TAGS.get(k)
    exif_table[tag]=v
    print("tag: ", tag, ", value: ", v)



#Import GPSTAGS
from PIL.ExifTags import GPSTAGS
print(GPSTAGS)
gps_info={}
for k, v in exif_table['GPSInfo'].items():
    geo_tag=GPSTAGS.get(k)
    gps_info[geo_tag]=v
print(gps_info)
Output:
testjpg.py test.py ImageWidth : 4000 ImageLength : 2250 BitsPerSample : (8, 8, 8) GPSInfo : 746 ResolutionUnit : 2 ExifOffset : 332 ImageDescription : default Make : DJI Model : FC2204 Software : 10.00.11.04 Orientation : 1 YCbCrPositioning : 1 DateTime : 2020:01:01 12:28:10 SamplesPerPixel : 3 XResolution : 72.0 YResolution : 72.0 XPComment : b'0\x00.\x009\x00.\x001\x004\x002\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' XPKeywords : b's\x00i\x00n\x00g\x00l\x00e\x00' ['_ArrayData', '_Image__transformer', '_MpoImageFile__fp', '_MpoImageFile__frame', '_MpoImageFile__mpoffsets', '__array__', '__class__', '__copy__', '__delattr__', '__dict__', '__dir__', '__doc__', '__enter__', '__eq__', '__exit__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_after_jpeg_open', '_category', '_close__fp', '_close_exclusive_fp_after_loading', '_copy', '_crop', '_dump', '_ensure_mutable', '_exclusive_fp', '_exif', '_expand', '_get_safe_box', '_getexif', '_getmp', '_getxmp', '_min_frame', '_new', '_open', '_repr_png_', '_seek_check', '_size', 'adopt', 'alpha_composite', 'app', 'applist', 'bits', 'close', 'convert', 'copy', 'crop', 'custom_mimetype', 'decoderconfig', 'decodermaxblock', 'draft', 'effect_spread', 'entropy', 'filename', 'filter', 'format', 'format_description', 'fp', 'frombytes', 'get_format_mimetype', 'getbands', 'getbbox', 'getchannel', 'getcolors', 'getdata', 'getexif', 'getextrema', 'getim', 'getpalette', 'getpixel', 'getprojection', 'getxmp', 'height', 'histogram', 'huffman_ac', 'huffman_dc', 'icclist', 'im', 'info', 'is_animated', 'layer', 'layers', 'load', 'load_djpeg', 'load_end', 'load_prepare', 'load_read', 'load_seek', 'mode', 'mpinfo', 'n_frames', 'offset', 'palette', 'paste', 'point', 'putalpha', 'putdata', 'putpalette', 'putpixel', 'pyaccess', 'quantization', 'quantize', 'readonly', 'reduce', 'remap_palette', 'resize', 'rotate', 'save', 'seek', 'show', 'size', 'split', 'tell', 'thumbnail', 'tile', 'tobitmap', 'tobytes', 'toqimage', 'toqpixmap', 'transform', 'transpose', 'verify', 'width']
Larz60+ write Jun-01-2023, 08:40 AM:
Please use BBCode, specifically, 'python' and 'output' tags. rather than quote tags.
I changed this for you on this post.

Attached Files

Thumbnail(s)
   
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020