diff --git a/conf/header.html b/conf/header.html
index 632890a..adb1338 100644
--- a/conf/header.html
+++ b/conf/header.html
@@ -63,12 +63,12 @@
diff --git a/conf/main.css b/conf/main.css
index d31de3c..f2ae676 100644
--- a/conf/main.css
+++ b/conf/main.css
@@ -292,6 +292,10 @@ nav li {
}
}
+p {
+ margin-top:3cm;
+}
+
/* Arise Index Style */
.arise-toc-td {
border-width: 1px;
diff --git a/gps_location.py b/gps_location.py
index aaab50d..d290876 100755
--- a/gps_location.py
+++ b/gps_location.py
@@ -8,6 +8,7 @@ import os
import sys
import requests
import json
+import time
from datetime import datetime
from PIL import Image
from PIL.ExifTags import TAGS, GPSTAGS
@@ -80,19 +81,30 @@ def get_lat_lon(exif_data):
return lat, lon
+
def getReverseAPI(lat, lon):
try:
+ time.sleep(1)
payload = {"lat": lat, "lon": lon, "format": "json", "addressdetails": "1"}
r = requests.get(REV_API_URL, headers=headers, params=payload)
return r.json()
except requests.exceptions.HTTPError as errh:
- print ("Http Error:",errh)
+ print("Http Error:", errh)
except requests.exceptions.ConnectionError as errc:
- print ("Error Connecting:",errc)
+ print("Error Connecting:", errc)
except requests.exceptions.Timeout as errt:
- print ("Timeout Error:",errt)
+ print("Timeout Error:", errt)
except requests.exceptions.RequestException as err:
- print ("OOps: Something Else",err)
+ print("OOps: Something Else", err)
+
+def getPlace(geo):
+ if geo.get('name'):
+ return geo.get('name')
+ else:
+ place = geo['address'].get('city') or geo['address'].get('town') or geo['address'].get('village') or geo['address'].get('hamlet') or geo['address'].get('isolated_dwelling')
+ if geo['address'].get('road'):
+ place += ", " + geo['address'].get('road')
+ return place
def getCity(geo):
return geo["address"]["city"] or ""
diff --git a/purrpic.py b/purrpic.py
old mode 100644
new mode 100755
index f289b24..dcc1f42
--- a/purrpic.py
+++ b/purrpic.py
@@ -6,7 +6,6 @@
import os
import sys
-import glob
from PIL import Image
from PIL.ExifTags import TAGS, GPSTAGS
@@ -14,10 +13,11 @@ import argparse
import configparser
from pathlib import Path
import datetime
-from gps_location import get_lat_lon, getReverseAPI
+from gps_location import get_lat_lon, getReverseAPI, getPlace
+from fractions import Fraction
-BUILD_DIR = Path("./build").resolve()
-CONF_DIR = Path("./conf").resolve()
+BUILD_DIR = Path("/home/chrissy/repos/purrpic/build").resolve()
+CONF_DIR = Path("/home/chrissy/repos/purrpic//conf").resolve()
THUMBSIZE = (800, 800)
GLOBALNAME = "Chrissys random Photogallery"
LICENCE = "CC BY-NC-SA 4.0"
@@ -42,6 +42,7 @@ class HTML:
self.lat = None
self.lon = None
self.geo = None
+ self.place = None
self.datetime = None
self.file_link = None
self.make = None
@@ -53,9 +54,11 @@ class HTML:
self.exposure = None
self.exposure_mode = None
self.exposure_program = None
+ self.exposure_bias = None
self.f_num = None
self.flash = None
self.focal_length = None
+ self.focal_length_35mm = None
self.focus_distance = None
self.focus_mode = None
self.iso = None
@@ -133,11 +136,17 @@ class HTML:
if "FocalLength" in exifdata:
self.focal_length = exifdata["FocalLength"]
+ if 'FocalLengthIn35mmFilm' in exifdata and exifdata.get('FocalLengthIn35mmFilm') != 0:
+ self.focal_length_35mm = exifdata.get('FocalLengthIn35mmFilm')
+
if "LensModel" in exifdata:
self.lens_model = exifdata["LensModel"]
if "ExposureTime" in exifdata:
- self.exposure = exifdata["ExposureTime"]
+ self.exposure = f"1/{round(1/float(exifdata.get('ExposureTime')))}"
+
+ if 'ExposureBiasValue' in exifdata:
+ self.exposure_bias = exifdata.get('ExposureBiasValue')
if "FNumber" in exifdata:
self.f_num = exifdata["FNumber"]
@@ -151,12 +160,14 @@ class HTML:
if "GPSInfo" in exifdata:
self.lat, self.lon = get_lat_lon(exifdata)
self.geo = getReverseAPI(self.lat, self.lon)
+ self.place = getPlace(self.geo)
+
+
def writeGrid(self, imglist, linklist):
try:
buf: ""
buf += self.div("row")
- # imglist = glob.glob(str(odir) + "/.thumbnails/*")
imglist = []
for img in Path.iterdir(odir / ".thumbnails"):
imglist.append(img)
@@ -172,6 +183,7 @@ class HTML:
def writeIndex(self, odir, meta) -> None:
try:
+ print(f"Writing index.html for {odir}")
title = meta["title"]
desc = meta["description"]
buf = self.headermeta(title)
@@ -180,7 +192,7 @@ class HTML:
buf += self.ul()
for line in desc:
buf += self.li(line)
- buf += self.li(f"© {AUTHOR}, {LICENCE}")
+ buf += self.li(f"© {AUTHOR}, {LICENCE}")
buf += self.endUl()
buf += self.div("row")
imglist = []
@@ -202,7 +214,6 @@ class HTML:
def writeDetail(self, odir):
try:
- breakpoint()
imglist = []
for file in Path.iterdir(odir):
if file.suffix in [".jpg", ".png", "JPEG", "PNG"]:
@@ -216,9 +227,10 @@ class HTML:
buf += self.div("div")
buf += self.div("divleft")
buf += self.link("index.html", "Back")
+ buf +="
"
buf += self.endDiv()
buf += self.endDiv()
- buf += self.img(img)
+ buf += self.aimg(img.name, img.name)
buf += self.div("div")
if imglist.index(img) != 0:
buf += self.div("divleft")
@@ -237,41 +249,46 @@ class HTML:
buf += self.endDiv()
buf += self.endDiv()
+ buf +="
"
buf += self.div("div")
- buf += '
| Time | {self.datetime.strftime('%Y-%m-%d %H:%M')} |
| Time | {self.datetime.strftime('%Y-%m-%d %H:%M')} |
| Place | {self.geo['address']['road']}, {self.geo['address']['town']} |
| Place | {self.place} |
| Camera | {self.make} {self.model} |
| Camera | {self.make} {self.model} |
| Lens Model | {self.lens_model} |
| Lens Model | {self.lens_model} |
| Focal Length | {self.focal_length} |
| Focal Length | {self.focal_length} |
| Aperture | {self.focal_length} |
| Aperture | {self.f_num} |
| Exposure Time | {self.exposure} |
| Exposure Time | {self.exposure} |
| ISO | {self.iso} |
| ISO | {self.iso} |
| Software | {self.software} |
| Software | {self.software} |