|
|
|
@ -9,9 +9,11 @@ from shutil import move
|
|
|
|
import sqlite3
|
|
|
|
import sqlite3
|
|
|
|
|
|
|
|
|
|
|
|
# update database residing here
|
|
|
|
# update database residing here
|
|
|
|
DB_LOCATION = "db/photovoter.dblite" # Q: any allowances for this being not OUR database?
|
|
|
|
DB_LOCATION = (
|
|
|
|
|
|
|
|
"db/photovoter.dblite" # Q: any allowances for this being not OUR database?
|
|
|
|
|
|
|
|
)
|
|
|
|
# place compressed images here (needs to exist)
|
|
|
|
# place compressed images here (needs to exist)
|
|
|
|
DEST_STRUNK = "db/image/"
|
|
|
|
DEST_SHRUNK = "db/image/"
|
|
|
|
# move originals here (needs to exist)
|
|
|
|
# move originals here (needs to exist)
|
|
|
|
DEST_ORIGINAL = "db/original/"
|
|
|
|
DEST_ORIGINAL = "db/original/"
|
|
|
|
|
|
|
|
|
|
|
|
@ -23,10 +25,10 @@ def usage():
|
|
|
|
|
|
|
|
|
|
|
|
def process_pictures():
|
|
|
|
def process_pictures():
|
|
|
|
"""Process images from the base directory in the first command line argument.
|
|
|
|
"""Process images from the base directory in the first command line argument.
|
|
|
|
Place the resized copies to DEST_STRUNK and
|
|
|
|
Place the resized copies to DEST_SHRUNK and
|
|
|
|
move the originals to DEST_ORIGINAL.
|
|
|
|
move the originals to DEST_ORIGINAL.
|
|
|
|
Return a dict for each image processed for database collection.
|
|
|
|
Return a dict for each image processed for database collection.
|
|
|
|
Uses: DEST_STRUNK, DEST_ORIGINAL
|
|
|
|
Uses: DEST_SHRUNK, DEST_ORIGINAL
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
# walk every pic
|
|
|
|
# walk every pic
|
|
|
|
# We only care about files in the root of the path
|
|
|
|
# We only care about files in the root of the path
|
|
|
|
@ -48,7 +50,7 @@ def process_pictures():
|
|
|
|
cloned.strip() # Q: may damage icc, do we allow that or use smh else?
|
|
|
|
cloned.strip() # Q: may damage icc, do we allow that or use smh else?
|
|
|
|
cloned.transform(resize="50%") # Q: what do we want here?
|
|
|
|
cloned.transform(resize="50%") # Q: what do we want here?
|
|
|
|
# move them to the processed folder
|
|
|
|
# move them to the processed folder
|
|
|
|
cloned.save(filename=path.join(DEST_STRUNK, filename))
|
|
|
|
cloned.save(filename=path.join(DEST_SHRUNK, filename))
|
|
|
|
|
|
|
|
|
|
|
|
# move the originals out of the working directory
|
|
|
|
# move the originals out of the working directory
|
|
|
|
# Q: do we strip exif from originals?
|
|
|
|
# Q: do we strip exif from originals?
|
|
|
|
@ -56,7 +58,7 @@ def process_pictures():
|
|
|
|
|
|
|
|
|
|
|
|
# return the freshly processed picture info
|
|
|
|
# return the freshly processed picture info
|
|
|
|
yield {
|
|
|
|
yield {
|
|
|
|
"ResizedImage": path.join(DEST_STRUNK, filename),
|
|
|
|
"ResizedImage": path.join(DEST_SHRUNK, filename),
|
|
|
|
"OriginalImage": path.join(DEST_ORIGINAL, filename),
|
|
|
|
"OriginalImage": path.join(DEST_ORIGINAL, filename),
|
|
|
|
"DateTimeOriginal": exif["DateTimeOriginal"], # Q: normalize it?
|
|
|
|
"DateTimeOriginal": exif["DateTimeOriginal"], # Q: normalize it?
|
|
|
|
"GPSLatitude": exif["GPSLatitude"],
|
|
|
|
"GPSLatitude": exif["GPSLatitude"],
|
|
|
|
|