Get GPS data from images

I wanted to extract the gps coordinates of jpg images. I found this solution and modified it for my needs: https://gist.github.com/snakeye/fdc372dbf11370fe29eb

Requires: exifread

import sys
import exifread

def convert_to_degress(value):
    d = float(value.values[0].num) / float(value.values[0].den)
    m = float(value.values[1].num) / float(value.values[1].den)
    s = float(value.values[2].num) / float(value.values[2].den)

    return d + (m / 60.0) + (s / 3600.0)

def get_location(exif_data):
    latitude = exif_data.get('GPS GPSLatitude')
    latitude_ref = exif_data.get('GPS GPSLatitudeRef')
    longitude = exif_data.get('GPS GPSLongitude')
    longitude_ref = exif_data.get('GPS GPSLongitudeRef')

    if not (latitude and latitude_ref and longitude and longitude_ref):
        return None, None

    lat = convert_to_degress(latitude)
    if latitude_ref.values[0] != 'N':
        lat = 0 - lat

    lon = convert_to_degress(longitude)
    if longitude_ref.values[0] != 'E':
        lon = 0 - lon

    return lat, lon

with open(sys.argv[1], 'rb') as f:
    exif_tags = exifread.process_file(f)
lat, long = get_location(exif_tags)
print(lat, long)

This code reads a JPG image and prints latitude and longitude in decimals of that image.