|
|
|
@ -94,29 +94,24 @@ def export_kml_file(dirname, fnames, kml_name):
|
|
|
|
|
kml = simplekml.Kml()
|
|
|
|
|
|
|
|
|
|
for fname in fnames:
|
|
|
|
|
try:
|
|
|
|
|
with Image.open(os.path.join(dirname, fname)) as image:
|
|
|
|
|
exif_data = get_exif_data(image)
|
|
|
|
|
|
|
|
|
|
print('Reading {}...'.format(fname))
|
|
|
|
|
|
|
|
|
|
lat, lon = get_lat_lon(exif_data)
|
|
|
|
|
pnt = kml.newpoint(name=fname)
|
|
|
|
|
pnt.coords = [(lon, lat)]
|
|
|
|
|
|
|
|
|
|
# Add content to popup window
|
|
|
|
|
pnt.description = (
|
|
|
|
|
'<![CDATA[ <img src={} height="500px" />]]>'.format(
|
|
|
|
|
os.path.join(dirname, fname)))
|
|
|
|
|
pnt.stylemap.normalstyle.iconstyle.scale = 1
|
|
|
|
|
pnt.stylemap.normalstyle.iconstyle.icon.href = (
|
|
|
|
|
'http://maps.google.com/'
|
|
|
|
|
'mapfiles/kml/shapes/camera.png')
|
|
|
|
|
pnt.stylemap.highlightstyle.iconstyle.scale = 2
|
|
|
|
|
pnt.stylemap.highlightstyle.iconstyle.icon.href = os.path.join(
|
|
|
|
|
dirname, fname)
|
|
|
|
|
except OSError:
|
|
|
|
|
print('Skipping {} (not a valid image).'.format(fname))
|
|
|
|
|
print('Reading {}...'.format(fname))
|
|
|
|
|
with Image.open(os.path.join(dirname, fname)) as image:
|
|
|
|
|
exif_data = get_exif_data(image)
|
|
|
|
|
|
|
|
|
|
lat, lon = get_lat_lon(exif_data)
|
|
|
|
|
pnt = kml.newpoint(name=fname)
|
|
|
|
|
pnt.coords = [(lon, lat)]
|
|
|
|
|
|
|
|
|
|
# Add content to popup window
|
|
|
|
|
pnt.description = ('<![CDATA[ <img src={} height="500px" />]]>'.format(
|
|
|
|
|
os.path.join(dirname, fname)))
|
|
|
|
|
pnt.stylemap.normalstyle.iconstyle.scale = 1
|
|
|
|
|
pnt.stylemap.normalstyle.iconstyle.icon.href = (
|
|
|
|
|
'http://maps.google.com/'
|
|
|
|
|
'mapfiles/kml/shapes/camera.png')
|
|
|
|
|
pnt.stylemap.highlightstyle.iconstyle.scale = 2
|
|
|
|
|
pnt.stylemap.highlightstyle.iconstyle.icon.href = os.path.join(
|
|
|
|
|
dirname, fname)
|
|
|
|
|
|
|
|
|
|
kml.save(kml_name)
|
|
|
|
|
|
|
|
|
@ -128,8 +123,9 @@ def main():
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
# Get files in image directory
|
|
|
|
|
ext = ['.jpg', '.jpeg', '.tif', '.tiff']
|
|
|
|
|
dirname = args.folder
|
|
|
|
|
fnames = os.listdir(dirname)
|
|
|
|
|
fnames = [f for f in os.listdir(dirname) if os.path.splitext(f)[-1] in ext]
|
|
|
|
|
|
|
|
|
|
# Create kml file
|
|
|
|
|
kml_name = dirname + '.kml'
|
|
|
|
|