mirror of
https://github.com/Terranom674/Piwigo_Bratonien_Tools.git
synced 2026-09-20 09:55:58 +00:00
Fix Nextcloud image dimension XML parsing
This commit is contained in:
@@ -56,8 +56,30 @@ def safe_local_name(name: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def parse_image_dimensions(prop: ET.Element) -> tuple[int, int]:
|
def parse_image_dimensions(prop: ET.Element) -> tuple[int, int]:
|
||||||
for property_name in ("file-metadata-size", "metadata-photos-size"):
|
for property_name in ("metadata-photos-size", "file-metadata-size"):
|
||||||
raw = prop.findtext(f"{{{NC}}}{property_name}", default="").strip()
|
element = prop.find(f"{{{NC}}}{property_name}")
|
||||||
|
if element is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
width = 0
|
||||||
|
height = 0
|
||||||
|
for child in list(element):
|
||||||
|
local_name = child.tag.rsplit("}", 1)[-1]
|
||||||
|
text = (child.text or "").strip()
|
||||||
|
if not text:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
value = int(text)
|
||||||
|
except ValueError:
|
||||||
|
continue
|
||||||
|
if local_name == "width":
|
||||||
|
width = value
|
||||||
|
elif local_name == "height":
|
||||||
|
height = value
|
||||||
|
if width > 0 and height > 0:
|
||||||
|
return width, height
|
||||||
|
|
||||||
|
raw = (element.text or "").strip()
|
||||||
if not raw:
|
if not raw:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user