Используя сценарий Exp-11.py, укажите в качестве базовой линии следующее назначение:
1) Разрешите пользователю ввести путь
2) Используя этот путь, обработайте все файлы .jpg, содержащиеся в этой папке (обратите внимание, что вам нужно будет создать каталог с изображениями jpg)
3) Извлечь, EXIF данные из каждого из изображений и создать красивый вывод таблицы. Обратите внимание, что вы go выйдете за рамки базовых данных и извлечете все данные камеры или фотографии для каждой фотографии.
4) Нанесите геолокацию каждого изображения на карту.
(обратите внимание, что есть несколько способов сделать это). Однако самым простым способом будет использование приложения MapMaker, на https://mapmakerapp.com/ вы можете либо вручную ввести значения широты / долготы. код генерирует или вы можете поместить свои результаты в CSV-файл и загрузить данные на карту.
ПРИМЕЧАНИЕ, это ручной шаг процесса
5) Отправьте и ваш сценарий, и скриншот результатов.
Вот сценарий ... я абсолютно не знаю, откуда go отсюда. Я очень новичок в программировании, и я паникую
'''
EXIF Data Acquistion
January 2019
Version 1.1
'''
from __future__ import print_function
'''
Copyright (c) 2019 Chet Hosmer, Python Forensics
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
'''
# Usage Example:
# python Exp-11.py
#
# Requirement: Python 2.x or 3.x
#
# Requirement: 3rd Party Library that is utilized is: PILLOW
# pip install PILLOW from the command line
''' LIBRARY IMPORT SECTION '''
import os # Python Standard Library : Operating System Methods
import sys # Python Standard Library : System Methods
from datetime import datetime # Python Standard Libary datetime method from Standard Library
# import the Python Image Library
# along with TAGS and GPS related TAGS
# Note you must install the PILLOW Module
# pip install PILLOW
from PIL import Image
from PIL.ExifTags import TAGS, GPSTAGS
#?????????? is this where i need to put the "enter the path function"
# import the prettytable library
from prettytable import PrettyTable
def ExtractGPSDictionary(fileName):
''' Function to Extract GPS Dictionary '''
try:
pilImage = Image.open(fileName)
exifData = pilImage._getexif()
except Exception:
# If exception occurs from PIL processing
# Report the
return None, None
# Interate through the exifData
# Searching for GPS Tags
imageTimeStamp = "NA"
cameraModel = "NA"
cameraMake = "NA"
gpsData = False
gpsDictionary = {}
if exifData:
for tag, theValue in exifData.items():
# obtain the tag
tagValue = TAGS.get(tag, tag)
# Collect basic image data if available
if tagValue == 'DateTimeOriginal':
imageTimeStamp = exifData.get(tag).strip()
if tagValue == "Make":
cameraMake = exifData.get(tag).strip()
if tagValue == 'Model':
cameraModel = exifData.get(tag).strip()
# check the tag for GPS
if tagValue == "GPSInfo":
gpsData = True;
# Found it !
# Now create a Dictionary to hold the GPS Data
# Loop through the GPS Information
for curTag in theValue:
gpsTag = GPSTAGS.get(curTag, curTag)
gpsDictionary[gpsTag] = theValue[curTag]
basicExifData = [imageTimeStamp, cameraMake, cameraModel]
return gpsDictionary, basicExifData
else:
return None, None
# End ExtractGPSDictionary ============================
def ExtractLatLon(gps):
''' Function to Extract Lattitude and Longitude Values '''
# to perform the calcuation we need at least
# lat, lon, latRef and lonRef
try:
latitude = gps["GPSLatitude"]
latitudeRef = gps["GPSLatitudeRef"]
longitude = gps["GPSLongitude"]
longitudeRef = gps["GPSLongitudeRef"]
lat = ConvertToDegrees(latitude)
lon = ConvertToDegrees(longitude)
# Check Latitude Reference
# If South of the Equator then lat value is negative
if latitudeRef == "S":
lat = 0 - lat
# Check Longitude Reference
# If West of the Prime Meridian in
# Greenwich then the Longitude value is negative
if longitudeRef == "W":
lon = 0- lon
gpsCoor = {"Lat": lat, "LatRef":latitudeRef, "Lon": lon, "LonRef": longitudeRef}
return gpsCoor
except:
return None
# End Extract Lat Lon ==============================================
def ConvertToDegrees(gpsCoordinate):
''' Function to CONVERT GPS COORIDINATES TO DEGRESS '''
d0 = gpsCoordinate[0][0]
d1 = gpsCoordinate[0][1]
try:
degrees = float(d0) / float(d1)
except:
degrees = 0.0
m0 = gpsCoordinate[1][0]
m1 = gpsCoordinate[1][1]
try:
minutes = float(m0) / float(m1)
except:
minutes=0.0
s0 = gpsCoordinate[2][0]
s1 = gpsCoordinate[2][1]
try:
seconds = float(s0) / float(s1)
except:
seconds = 0.0
floatCoordinate = float (degrees + (minutes / 60.0) + (seconds / 3600.0))
return floatCoordinate
''' MAIN PROGRAM ENTRY SECTION '''
if __name__ == "__main__":
'''
pyExif Main Entry Point
'''
print("\nExtract EXIF Data from JPEG Files")
print("Script Started", str(datetime.now()))
print()
''' PROCESS EACH JPEG FILE SECTION '''
latLonList = []
targetFile = "test.jpg" # file must be located in the same folder
if os.path.isfile(targetFile):
gpsDictionary, exifList = ExtractGPSDictionary(targetFile)
if exifList:
TS = exifList[0]
MAKE = exifList[1]
MODEL = exifList[2]
else:
TS = 'NA'
MAKE = 'NA'
MODEL = 'NA'
print("Photo Details")
print("-------------")
print("TimeStamp: ", TS)
print("Camera Make: ", MAKE)
print("Camera Model: ", MODEL)
if (gpsDictionary != None):
# Obtain the Lat Lon values from the gpsDictionary
# Converted to degrees
# The return value is a dictionary key value pairs
dCoor = ExtractLatLon(gpsDictionary)
print("\nGeo-Location Data")
print("-----------------")
if dCoor:
lat = dCoor.get("Lat")
latRef = dCoor.get("LatRef")
lon = dCoor.get("Lon")
lonRef = dCoor.get("LonRef")
if ( lat and lon and latRef and lonRef):
print("Lattitude: ", '{:4.4f}'.format(lat))
print("Longitude: ", '{:4.4f}'.format(lon))
else:
print("WARNING No GPS EXIF Data")
else:
print("WARNING No GPS EXIF Data")
else:
print("WARNING", " not a valid file", targetFile)
# Create Result Table Display using PrettyTable
''' GENERATE RESULTS TABLE SECTION'''
''' Result Table Heading'''
resultTable = PrettyTable(['File-Name', 'Lat','Lon', 'TimeStamp', 'Make', 'Model'])
''' Your work starts here '''
print()