code: def get_metadata_as_dict(fname):
      
      imgdict = {}
      try:
          imgdict['filename'] = fname
          imgdict['size'] = str(os.path.getsize(fname)) 
          imgdict['basename'] = os.path.basename(fname)
          imgdict['path'] = os.path.dirname(fname)
          img = Image.open(fname)
          # get the image's width and height in pixels
          width, height = img.size
          imgdict['width'] = str(width)
          imgdict['height'] = str(height)
          imgdict['format'] = str(img.format) 
          imgdict['palette'] = str(img.palette)
          stat = ImageStat.Stat(img)
           
          #res = res + q + str(stat.extrema) + q + d
          imgdict['count'] =  List2String(stat.count, ",")
          imgdict['sum'] =  List2String(stat.sum, ",")
          imgdict['sum2'] =  List2String(stat.sum2, ",")
          imgdict['mean'] =  List2String(stat.mean, ",") 
          imgdict['median'] =  List2String(stat.median, ",") 
          imgdict['rms'] =  List2String(stat.rms, ",") 
          imgdict['var'] =  List2String(stat.var, ",")
          imgdict['stddev'] =  List2String(stat.stddev, ",") 
  
          exif_data = get_exif_data(img)
          print('exif_data = ', exif_data)
          (lat, lon) = get_lat_lon(exif_data)
          print('(lat, lon)', (lat, lon))
          imgdict['lat'] =  str(lat)
          imgdict['lon'] =  str(lon)
      except Exception as ex:
          print('problem reading image file metadata in ', fname, str(ex))
          imgdict['lat'] =  'ERROR'
          imgdict['lon'] =  'ERROR'
      return imgdict
docs: Gets all metadata and puts into dictionary