fix: honor Synology photo orientation before landscape rendering
Community checks / verify (push) Skipped
Verify Frame Flow / verify (push) Successful in 5m25s

This commit is contained in:
渡口浪人
2026-10-18 17:43:25 +08:00
parent 038b858eb7
commit 51d76a196e
11 changed files with 110 additions and 14 deletions
+16 -2
View File
@@ -662,13 +662,27 @@ class PhotoSources:
data = self.assets.fetch_url(item["id"], headers=self.headers(source))
if len(data) > self.settings.max_bytes:
raise FlowError(E.INVALID_REQUEST, "Image exceeds size limit")
if source.minimum_short_edge or source.minimum_long_edge:
if source.orientation or source.minimum_short_edge or source.minimum_long_edge:
from io import BytesIO
from PIL import Image
with Image.open(BytesIO(data)) as image:
if not self.resolution_matches(source, *image.size):
width, height = image.size
if image.getexif().get(274, 1) in (5, 6, 7, 8):
width, height = height, width
wanted = (
orientation(*target_size)
if source.orientation == "auto"
else source.orientation
)
# Validate the fetched rendition before a crop can hide a mismatch.
if wanted and orientation(width, height) != wanted:
raise FlowError(
E.INVALID_REQUEST,
"Photo direction does not match the source orientation",
)
if not self.resolution_matches(source, width, height):
raise FlowError(
E.INVALID_REQUEST,
"Photo is below the configured minimum resolution",