Handle invalid random photos before device writes and trace selections
This commit is contained in:
@@ -11,7 +11,8 @@ from pigway_frame_flow.errors import ErrorCode as E
|
||||
from pigway_frame_flow.errors import FlowError
|
||||
from pigway_frame_flow.storage.database import now_iso
|
||||
|
||||
Image.MAX_IMAGE_PIXELS = 25_000_000
|
||||
MAX_IMAGE_PIXELS = 25_000_000
|
||||
Image.MAX_IMAGE_PIXELS = MAX_IMAGE_PIXELS
|
||||
|
||||
|
||||
def convert(data, fit="contain", profile="color", *, size=(1200, 1600)):
|
||||
@@ -19,7 +20,7 @@ def convert(data, fit="contain", profile="color", *, size=(1200, 1600)):
|
||||
with Image.open(BytesIO(data)) as source:
|
||||
if source.format not in {"JPEG", "PNG", "WEBP"}:
|
||||
raise ValueError()
|
||||
if source.width * source.height > 25_000_000:
|
||||
if source.width * source.height > MAX_IMAGE_PIXELS:
|
||||
raise ValueError()
|
||||
img = ImageOps.exif_transpose(source).convert("RGBA")
|
||||
canvas = Image.new("RGBA", img.size, "white")
|
||||
|
||||
Reference in New Issue
Block a user