diff --git a/photoapp/image.py b/photoapp/image.py index a90a7e3..04f5735 100644 --- a/photoapp/image.py +++ b/photoapp/image.py @@ -25,7 +25,8 @@ def get_jpg_info(fpath): size = os.path.getsize(fpath) photo = Photo(hash=get_hash(fpath), path=fpath, format=mime, size=size, - width=dimensions[0], height=dimensions[1], orientation=orientation) + width=dimensions[0], height=dimensions[1], + orientation=orientation, fname=os.path.basename(fpath)) return PhotoSet(date=date, date_real=date, lat=lat, lon=lon, files=[photo]) diff --git a/photoapp/ingest.py b/photoapp/ingest.py index c021906..b1f2918 100644 --- a/photoapp/ingest.py +++ b/photoapp/ingest.py @@ -58,7 +58,7 @@ def get_photosets(files): # process raws for item in chain(*[byext[ext] for ext in files_raw]): itemmeta = Photo(hash=get_hash(item), path=item, size=os.path.getsize(item), - format=special_magic(item)) + format=special_magic(item), fname=os.path.basename(item)) fprefix = os.path.basename(item)[::-1].split(".", 1)[-1][::-1] fmatch = "{}.jpg".format(fprefix.lower()) # if we're inspecting "foobar.raw", match it with "foobar.jpg" # TODO does this account for extension mappinh like jpeg->jpg? @@ -80,7 +80,7 @@ def get_photosets(files): # process other known formats for item in chain(*[byext[ext] for ext in files_video]): itemmeta = Photo(hash=get_hash(item), path=item, size=os.path.getsize(item), - format=special_magic(item)) + format=special_magic(item), fname=os.path.basename(item)) mtime = get_mtime(item) photosets.append(PhotoSet(date=mtime, date_real=mtime, files=[itemmeta])) diff --git a/photoapp/types.py b/photoapp/types.py index d60de16..dcf332f 100644 --- a/photoapp/types.py +++ b/photoapp/types.py @@ -92,10 +92,11 @@ class Photo(Base): hash = Column(String(length=64), unique=True) path = Column(Unicode) format = Column(String(length=64)) # TODO how long can a mime string be + fname = Column(String(length=64)) # seems generous enough def to_json(self): j = {attr: getattr(self, attr) for attr in - {"uuid", "size", "width", "height", "orientation", "format", "hash"}} + {"uuid", "size", "width", "height", "orientation", "format", "hash", "fname"}} j["set"] = self.set.uuid if self.set else None return j diff --git a/templates/photo.html b/templates/photo.html index e18c596..b430cee 100644 --- a/templates/photo.html +++ b/templates/photo.html @@ -48,7 +48,7 @@
  • Versions: {{ image.files|length }}
  • - {% if image.lat != 0 %} + {% if image.lat %}
  • Coordinates: {{ image.lat }}, {{ image.lon }}
  • @@ -65,7 +65,10 @@
    - {{ img.uuid }} + {{ img.uuid }} +
    +
    + {{ img.fname }}
    {{ img.path | basename }}