misc tweaks and gps interpreting fixes

This commit is contained in:
dave 2021-07-07 19:50:15 -07:00
parent 7d5954a884
commit 6c4c1c609a
5 changed files with 37 additions and 16 deletions

View File

@ -114,8 +114,11 @@ This would ingest all the files listed in `shas.txt` that aren't already in the
Roadmap Roadmap
------- -------
- Fix Dates and Stats under mysql - On map page, provide a link back to the mapped set
- Flesh out CLI: - Flesh out CLI:
- data manipulation
- combine photosets
- split photosets
- Relink function - make a photo a member of another photo - Relink function - make a photo a member of another photo
- Config that is saved somewhere - Config that is saved somewhere
- Album features - Album features
@ -136,3 +139,6 @@ Roadmap
- dark theme - dark theme
- more information from the images like on http://exif.regex.info/exif.cgi - more information from the images like on http://exif.regex.info/exif.cgi
- my photos problems
- recently imported imotrip photos not time offset lol
- time offset options in ui?

View File

@ -168,6 +168,7 @@ class PhotosApiV1(object):
@cherrypy.expose @cherrypy.expose
def download(self, uuid): def download(self, uuid):
#TODO fix me
f = db.query(Photo).filter(Photo.uuid == uuid).first() f = db.query(Photo).filter(Photo.uuid == uuid).first()
if not f: if not f:
raise cherrypy.HTTPError(404) raise cherrypy.HTTPError(404)

View File

@ -141,6 +141,7 @@ def get_args():
p_dupes = sp_action.add_parser("checkdupes", help="check if files/hash lists are already in the library") p_dupes = sp_action.add_parser("checkdupes", help="check if files/hash lists are already in the library")
p_dupes.add_argument("--sha-files", action="store_true", help="read hashes from a file instead of hashing images") p_dupes.add_argument("--sha-files", action="store_true", help="read hashes from a file instead of hashing images")
# p_dupes.add_argument("--print-uuids", action="store_true", help="lookup and print uuids of duplicate files instead")
p_dupes.add_argument("files", nargs="+", help="files to check") p_dupes.add_argument("files", nargs="+", help="files to check")
p_ingest = sp_action.add_parser("ingest", help="import images into the library") p_ingest = sp_action.add_parser("ingest", help="import images into the library")
@ -149,6 +150,10 @@ def get_args():
p_ingest.add_argument("-t", "--tag", help="tag name to apply to the import") p_ingest.add_argument("-t", "--tag", help="tag name to apply to the import")
p_ingest.add_argument("files", nargs="+", help="files to import") p_ingest.add_argument("files", nargs="+", help="files to import")
# p_merge = sp_action.add_parser("merge", help="merge photoset copies into a master")
# p_merge.add_argument("-m", "--master", required=True, help="master photoset uuid")
# p_merge.add_argument("-c", "--copies", required=True, nargs="+", help="other photoset uuids")
sp_action.add_parser("stats", help="show library statistics") sp_action.add_parser("stats", help="show library statistics")
p_list = sp_action.add_parser("list", help="list images in library") p_list = sp_action.add_parser("list", help="list images in library")

View File

@ -174,7 +174,6 @@ class PhotosWeb(object):
/login - enable super features by logging into the app /login - enable super features by logging into the app
""" """
cherrypy.session['authed'] = cherrypy.request.login cherrypy.session['authed'] = cherrypy.request.login
print("Authed as", cherrypy.session['authed'])
dest = "/feed" if "Referer" not in cherrypy.request.headers \ dest = "/feed" if "Referer" not in cherrypy.request.headers \
else urlparse(cherrypy.request.headers["Referer"]).path else urlparse(cherrypy.request.headers["Referer"]).path
raise cherrypy.HTTPRedirect(dest, 302) raise cherrypy.HTTPRedirect(dest, 302)

View File

@ -89,20 +89,34 @@ def get_exif_data_fobj(fobj):
if orien: if orien:
orientationinfo = {0: 0, 8: 1, 3: 2, 6: 3}.get(int(orien), 0) orientationinfo = {0: 0, 8: 1, 3: 2, 6: 3}.get(int(orien), 0)
gps = exif.get("GPSInfo") gpsinfo = parse_exif_gps(exif.get("GPSInfo"))
if gps and 1 in gps and 2 in gps and 3 in gps and 4 in gps:
# see https://gis.stackexchange.com/a/273402
gps_y = round(hms_to_decimal(rational64u_to_hms(gps[2])), 8)
gps_x = round(hms_to_decimal(rational64u_to_hms(gps[4])), 8)
if gps[1] == 'S':
gps_y *= -1
if gps[3] == 'W':
gps_x *= -1
gpsinfo = (gps_y, gps_x)
return dateinfo, gpsinfo, sizeinfo, orientationinfo return dateinfo, gpsinfo, sizeinfo, orientationinfo
def parse_exif_gps(gps):
if not gps or 1 not in gps or 2 not in gps or 3 not in gps or 4 not in gps:
return None
if gps[1] not in {"N", "S"} or gps[3] not in {"E", "W"}:
return None
try:
y_decimal = rational64u_to_hms(gps[2])
x_decimal = rational64u_to_hms(gps[4])
except TypeError:
return None
# see https://gis.stackexchange.com/a/273402
gps_y = round(hms_to_decimal(y_decimal), 8)
gps_x = round(hms_to_decimal(x_decimal), 8)
if gps[1] == 'S':
gps_y *= -1
if gps[3] == 'W':
gps_x *= -1
return (gps_y, gps_x)
def rational64u_to_hms(values): def rational64u_to_hms(values):
return [Decimal(values[0].numerator) / Decimal(values[0].denominator), return [Decimal(values[0].numerator) / Decimal(values[0].denominator),
Decimal(values[1].numerator) / Decimal(values[1].denominator), Decimal(values[1].numerator) / Decimal(values[1].denominator),
@ -125,7 +139,3 @@ def special_magic_fobj(fobj, fname):
return "application/octet-stream-xmp" return "application/octet-stream-xmp"
else: else:
return magic.from_buffer(fobj.read(1024), mime=True) return magic.from_buffer(fobj.read(1024), mime=True)
def main():
print(get_exif_data("library/2018/9/8/MMwo4hr.jpg"))