diff --git a/README.md b/README.md index dd2bd10..54305de 100644 --- a/README.md +++ b/README.md @@ -114,8 +114,11 @@ This would ingest all the files listed in `shas.txt` that aren't already in the Roadmap ------- -- Fix Dates and Stats under mysql +- On map page, provide a link back to the mapped set - Flesh out CLI: + - data manipulation + - combine photosets + - split photosets - Relink function - make a photo a member of another photo - Config that is saved somewhere - Album features @@ -136,3 +139,6 @@ Roadmap - dark theme - 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? diff --git a/photoapp/api.py b/photoapp/api.py index f350483..810ccc0 100644 --- a/photoapp/api.py +++ b/photoapp/api.py @@ -168,6 +168,7 @@ class PhotosApiV1(object): @cherrypy.expose def download(self, uuid): + #TODO fix me f = db.query(Photo).filter(Photo.uuid == uuid).first() if not f: raise cherrypy.HTTPError(404) diff --git a/photoapp/cli.py b/photoapp/cli.py index f73753b..28f363d 100644 --- a/photoapp/cli.py +++ b/photoapp/cli.py @@ -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.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_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("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") p_list = sp_action.add_parser("list", help="list images in library") diff --git a/photoapp/daemon.py b/photoapp/daemon.py index ed63579..61aa50a 100644 --- a/photoapp/daemon.py +++ b/photoapp/daemon.py @@ -174,7 +174,6 @@ class PhotosWeb(object): /login - enable super features by logging into the app """ cherrypy.session['authed'] = cherrypy.request.login - print("Authed as", cherrypy.session['authed']) dest = "/feed" if "Referer" not in cherrypy.request.headers \ else urlparse(cherrypy.request.headers["Referer"]).path raise cherrypy.HTTPRedirect(dest, 302) diff --git a/photoapp/image.py b/photoapp/image.py index 826e14f..fbc2d53 100644 --- a/photoapp/image.py +++ b/photoapp/image.py @@ -89,20 +89,34 @@ def get_exif_data_fobj(fobj): if orien: orientationinfo = {0: 0, 8: 1, 3: 2, 6: 3}.get(int(orien), 0) - 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) + gpsinfo = parse_exif_gps(exif.get("GPSInfo")) 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): return [Decimal(values[0].numerator) / Decimal(values[0].denominator), Decimal(values[1].numerator) / Decimal(values[1].denominator), @@ -125,7 +139,3 @@ def special_magic_fobj(fobj, fname): return "application/octet-stream-xmp" else: return magic.from_buffer(fobj.read(1024), mime=True) - - -def main(): - print(get_exif_data("library/2018/9/8/MMwo4hr.jpg"))