mirror of
https://github.com/greflm13/StaticGalleryBuilder.git
synced 2026-02-05 02:59:27 +00:00
added exifdata to sizelist
This commit is contained in:
@@ -101,7 +101,7 @@
|
|||||||
"editor.defaultFormatter": "ms-python.black-formatter",
|
"editor.defaultFormatter": "ms-python.black-formatter",
|
||||||
},
|
},
|
||||||
"black-formatter.args": [
|
"black-formatter.args": [
|
||||||
"-l 140",
|
"-l 260",
|
||||||
],
|
],
|
||||||
"black-formatter.interpreter": [
|
"black-formatter.interpreter": [
|
||||||
"/usr/bin/python3",
|
"/usr/bin/python3",
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from typing import Any, Dict, List, Tuple
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from tqdm.auto import tqdm
|
from tqdm.auto import tqdm
|
||||||
from PIL import Image, ExifTags
|
from PIL import Image, ExifTags, TiffImagePlugin
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
|
||||||
import modules.cclicense as cclicense
|
import modules.cclicense as cclicense
|
||||||
@@ -55,7 +55,7 @@ def initialize_sizelist(folder: str) -> Dict[str, Dict[str, int]]:
|
|||||||
return sizelist
|
return sizelist
|
||||||
|
|
||||||
|
|
||||||
def update_sizelist(sizelist: Dict[str, Dict[str, int]], folder: str) -> None:
|
def update_sizelist(sizelist: Dict[str, Dict[str, Any]], folder: str) -> None:
|
||||||
"""
|
"""
|
||||||
Updates the size list JSON file.
|
Updates the size list JSON file.
|
||||||
|
|
||||||
@@ -86,10 +86,33 @@ def get_image_info(item: str, folder: str) -> Dict[str, Any]:
|
|||||||
with Image.open(os.path.join(folder, item)) as img:
|
with Image.open(os.path.join(folder, item)) as img:
|
||||||
exif = img.getexif()
|
exif = img.getexif()
|
||||||
width, height = img.size
|
width, height = img.size
|
||||||
exifdata = {ExifTags.TAGS.get(key, key): val for key, val in exif.items()}
|
if exif:
|
||||||
if "Orientation" in exifdata and exifdata["Orientation"] in [6, 8]:
|
ifd = exif.get_ifd(ExifTags.IFD.Exif)
|
||||||
width, height = height, width
|
exifdatas = {key: val for key, val in exif.items()} | ifd
|
||||||
return {"width": width, "height": height}
|
exifdata = {}
|
||||||
|
for tag_id in exifdatas:
|
||||||
|
tag = ExifTags.TAGS.get(tag_id, tag_id)
|
||||||
|
content = exifdatas.get(tag_id)
|
||||||
|
if isinstance(content, bytes):
|
||||||
|
content = content.hex(" ")
|
||||||
|
if isinstance(content, TiffImagePlugin.IFDRational):
|
||||||
|
content = content.limit_rational(1000000)
|
||||||
|
if isinstance(content, tuple):
|
||||||
|
newtuple = ()
|
||||||
|
for i in content:
|
||||||
|
if isinstance(i, TiffImagePlugin.IFDRational):
|
||||||
|
newtuple = newtuple + (i.limit_rational(1000000),)
|
||||||
|
if newtuple:
|
||||||
|
content = newtuple
|
||||||
|
exifdata[tag] = content
|
||||||
|
if "Orientation" in exifdata and exifdata["Orientation"] in [6, 8]:
|
||||||
|
width, height = height, width
|
||||||
|
for key in ["PrintImageMatching", "UserComment", "MakerNote"]:
|
||||||
|
if key in exifdata:
|
||||||
|
del exifdata[key]
|
||||||
|
return {"width": width, "height": height, "exifdata": exifdata}
|
||||||
|
else:
|
||||||
|
return {"width": width, "height": height}
|
||||||
|
|
||||||
|
|
||||||
def process_image(item: str, folder: str, _args: Args, baseurl: str, sizelist: Dict[str, Dict[str, int]], raw: List[str]) -> Dict[str, Any]:
|
def process_image(item: str, folder: str, _args: Args, baseurl: str, sizelist: Dict[str, Dict[str, int]], raw: List[str]) -> Dict[str, Any]:
|
||||||
|
|||||||
Reference in New Issue
Block a user