Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,7 +10,7 @@ import gradio as gr
|
|
| 10 |
from datetime import datetime
|
| 11 |
import json
|
| 12 |
import re
|
| 13 |
-
import
|
| 14 |
|
| 15 |
# Initialize FastAPI app with increased upload limit (10MB)
|
| 16 |
app = FastAPI()
|
|
@@ -36,14 +36,14 @@ def resize_image(image: Image.Image, max_size: int = 1024) -> Image.Image:
|
|
| 36 |
# Extract EXIF metadata, including GPS and timestamp
|
| 37 |
def extract_metadata(image_data: bytes) -> dict:
|
| 38 |
try:
|
| 39 |
-
|
| 40 |
metadata = {
|
| 41 |
-
"timestamp":
|
| 42 |
"gps": {
|
| 43 |
-
"latitude":
|
| 44 |
-
"longitude":
|
| 45 |
},
|
| 46 |
-
"camera":
|
| 47 |
}
|
| 48 |
return metadata
|
| 49 |
except Exception as e:
|
|
|
|
| 10 |
from datetime import datetime
|
| 11 |
import json
|
| 12 |
import re
|
| 13 |
+
from exif import Image as ExifImage
|
| 14 |
|
| 15 |
# Initialize FastAPI app with increased upload limit (10MB)
|
| 16 |
app = FastAPI()
|
|
|
|
| 36 |
# Extract EXIF metadata, including GPS and timestamp
|
| 37 |
def extract_metadata(image_data: bytes) -> dict:
|
| 38 |
try:
|
| 39 |
+
exif_img = ExifImage(io.BytesIO(image_data))
|
| 40 |
metadata = {
|
| 41 |
+
"timestamp": exif_img.get("datetime_original", "N/A"),
|
| 42 |
"gps": {
|
| 43 |
+
"latitude": exif_img.get("gps_latitude", "N/A"),
|
| 44 |
+
"longitude": exif_img.get("gps_longitude", "N/A")
|
| 45 |
},
|
| 46 |
+
"camera": f"{exif_img.get('make', 'N/A')} {exif_img.get('model', 'N/A')}"
|
| 47 |
}
|
| 48 |
return metadata
|
| 49 |
except Exception as e:
|