|
|
|
|
@ -9,7 +9,7 @@ from shutil import move
|
|
|
|
|
import sqlite3
|
|
|
|
|
|
|
|
|
|
# update database residing here
|
|
|
|
|
DB_LOCATION = "../../testbox/photovoter.dblite"
|
|
|
|
|
DB_LOCATION = "../../testbox/photovoter.dblite" # Q: any allowances for this being not OUR database?
|
|
|
|
|
# place compressed images here (needs to exist)
|
|
|
|
|
DEST_STRUNK = "../../testbox/image/"
|
|
|
|
|
# move originals here (needs to exist)
|
|
|
|
|
@ -33,7 +33,7 @@ def process_pictures():
|
|
|
|
|
# Ignore any nested directories
|
|
|
|
|
(root, _, filenames) = next(walk(argv[1], topdown=True), (None, None, []))
|
|
|
|
|
for filename in filenames:
|
|
|
|
|
# FIXME:what if picture with the same name already exists?
|
|
|
|
|
# FIXME[0]:what if picture with the same name already exists?
|
|
|
|
|
# skip any non-image files
|
|
|
|
|
if not filetype.image_match(path.join(root, filename)):
|
|
|
|
|
continue
|
|
|
|
|
@ -66,15 +66,41 @@ def process_pictures():
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_database():
|
|
|
|
|
def update_database(pic_info: dict):
|
|
|
|
|
"""Append new image information to the existing database
|
|
|
|
|
or create a new one, if it does not exist yet
|
|
|
|
|
Uses: DB_LOCATION
|
|
|
|
|
"""
|
|
|
|
|
# make sure the database exists
|
|
|
|
|
check_database(DB_LOCATION)
|
|
|
|
|
|
|
|
|
|
# FIXME[1]: closure it, so we open it only once?
|
|
|
|
|
con = sqlite3.connect(DB_LOCATION)
|
|
|
|
|
cur = con.cursor()
|
|
|
|
|
# insert new pictures to the image table
|
|
|
|
|
pass
|
|
|
|
|
cur.execute(
|
|
|
|
|
"""INSERT INTO images(resizedpath,
|
|
|
|
|
origpath,
|
|
|
|
|
date,
|
|
|
|
|
GPSLatitude,
|
|
|
|
|
GPSLatitudeRef,
|
|
|
|
|
GPSLongitude,
|
|
|
|
|
GPSLongitudeRef)
|
|
|
|
|
|
|
|
|
|
VALUES (:ResizedImage,
|
|
|
|
|
:OriginalImage,
|
|
|
|
|
:DateTimeOriginal,
|
|
|
|
|
:GPSLatitude,
|
|
|
|
|
:GPSLatitudeRef,
|
|
|
|
|
:GPSLongitude,
|
|
|
|
|
:GPSLongitudeRef)
|
|
|
|
|
""",
|
|
|
|
|
pic_info,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
con.commit()
|
|
|
|
|
# FIXME[1]
|
|
|
|
|
con.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_database(database_path: str):
|
|
|
|
|
@ -118,8 +144,7 @@ def main():
|
|
|
|
|
pics_processed = 0
|
|
|
|
|
# process each pic and add it to the database
|
|
|
|
|
for pic in process_pictures():
|
|
|
|
|
update_database()
|
|
|
|
|
print(pic) # just print into strout for now
|
|
|
|
|
update_database(pic)
|
|
|
|
|
pics_processed += 1
|
|
|
|
|
|
|
|
|
|
if pics_processed == 0:
|
|
|
|
|
|