diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | src/main.py | 31 |
2 files changed, 18 insertions, 15 deletions
@@ -2,7 +2,7 @@ SHELL := /bin/bash remove_exif_except_gps: - exiftool -all= -tagsfromfile @ -gps:all -ImageUniqueID src/static/pics/mine/ + exiftool -overwrite_original -r -all= -tagsfromfile @ -gps:all -ImageUniqueID src/static/pics/mine/ source_images_add_uuid: exiftool -overwrite_original -r "-ImageUniqueID=$(uuidgen)" -if 'not $ImageUniqueID' original_pics/ diff --git a/src/main.py b/src/main.py index a3e6b11..6dae322 100644 --- a/src/main.py +++ b/src/main.py @@ -11,10 +11,6 @@ import geopy.distance app = flask.Flask(__name__) -pic_root_path = 'src/static/pics/mine' - -pics = os.listdir(pic_root_path) - def decimal_coords(coords, ref): decimal_degrees = coords[0] + coords[1] / 60 + coords[2] / 3600 if ref == "S" or ref =='W' : @@ -89,6 +85,23 @@ def game(): return flask.render_template('game.html') + +pic_root_path = 'src/static/pics/mine' +pics_original = os.listdir(pic_root_path) +pics = [] + +# Check if all images have GPS coordinates on application start +for pic in pics_original: + img_path = os.path.join(pic_root_path, pic) + try: + exif = get_exif(img_path) + correct_coordinates = image_coordinates(exif) + pics.append(pic) + except Exception as ex: + print(f'Error loading GPS coordinates for: {img_path}') + raise ex + + with closing(sqlite3.connect("guess_where.db")) as connection: with closing(connection.cursor()) as cursor: rows = cursor.execute(""" @@ -102,13 +115,3 @@ with closing(sqlite3.connect("guess_where.db")) as connection: ) """).fetchall() - - -# Check if all images have GPS coordinates on application start -for pic in pics: - img_path = os.path.join(pic_root_path, pic) - try: - correct_coordinates = image_coordinates(img_path) - except Exception as ex: - print(f'Error loading GPS coordinates for: {img_path}') - |
