new_contents: #!/usr/bin/env python
  
  import logging
  import exifread
  import os
  import shutil
  import hashlib
  import sys
  import time
  import datetime
  import ntpath
  import glob
  
  from geopy.geocoders import Nominatim
  
  
  #logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.WARNING)
  # create logger
  logger = logging.getLogger('getcity')
  logger.setLevel(logging.DEBUG)
  logFormatter = logging.Formatter("%(asctime)s [%(levelname)-5.5s]  %(message)s")
  consoleHandler = logging.StreamHandler()
  consoleHandler.setFormatter(logFormatter)
  logger.addHandler(consoleHandler)
  
  
  def _get_if_exist(data, key):
      if key in data:
          return data[key]
  
      return None
  
  
  def _convert_to_degress(value):
      """
      Helper function to convert the GPS coordinates stored in the EXIF to degress in float format
      :param value:
      :type value: exifread.utils.Ratio
      :rtype: float
      """
      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_exif_location(exif_data):
      """
      Returns the latitude and longitude, if available, from the provided exif_data (obtained through get_exif_data above)
      """
      lat = None
      lon = None
  
      gps_latitude = _get_if_exist(exif_data, 'GPS GPSLatitude')
      gps_latitude_ref = _get_if_exist(exif_data, 'GPS GPSLatitudeRef')
      gps_longitude = _get_if_exist(exif_data, 'GPS GPSLongitude')
      gps_longitude_ref = _get_if_exist(exif_data, 'GPS GPSLongitudeRef')
  
      if gps_latitude and gps_latitude_ref and gps_longitude and gps_longitude_ref:
          lat = _convert_to_degress(gps_latitude)
          if gps_latitude_ref.values[0] != 'N':
              lat = 0 - lat
  
          lon = _convert_to_degress(gps_longitude)
          if gps_longitude_ref.values[0] != 'E':
              lon = 0 - lon
  
      return lat, lon
  
  
  def get_image_location_name(filename):
      country = None
      city = None
  
      with open(filename,'rb') as file:
          data=exifread.process_file(file)
          if data:
             #logger.debug("data {}".format(data))
             (lat, lon) = get_exif_location(data)
             logger.debug("lat={}, lon={}".format(lat,lon))
             if lat and lon:
                 geolocator = Nominatim("%s",None,"US")
                 location = geolocator.reverse("{}, {}".format(lat,lon),True,20,"en-US")
                 logger.info(location.address)
          else:
             logger.debug("no EXIF in file {}".format(filename))
  
      return country, city
  
  
  filename=sys.argv[1]
  if not filename:
     logger.info('getcity.py <filename>')
     exit(1)
  
  get_image_location_name(filename)
  
subject: Create get-image-location.py