mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 01:04:32 +02:00
api resiliency improvements
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
@@ -18,10 +18,14 @@ def decode_base64_to_image(encoding, quiet=False):
|
||||
if encoding.startswith("data:image/"):
|
||||
encoding = encoding.split(";")[1].split(",")[1]
|
||||
try:
|
||||
image = Image.open(io.BytesIO(base64.b64decode(encoding)))
|
||||
decoded = base64.b64decode(encoding)
|
||||
data = io.BytesIO(decoded)
|
||||
image = Image.open(data)
|
||||
return image
|
||||
except Exception as e:
|
||||
shared.log.warning(f'API cannot decode image: {e}')
|
||||
from modules import errors
|
||||
errors.display(e, 'API cannot decode image')
|
||||
if not quiet:
|
||||
raise HTTPException(status_code=500, detail="Invalid encoded image") from e
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user