mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-12-06 10:31:17 -08:00
add images.read to automatically fix all jpeg/png weirdness
This commit is contained in:
parent
5625ce1b1a
commit
09b5ce68a9
6 changed files with 41 additions and 72 deletions
|
|
@ -85,8 +85,7 @@ def decode_base64_to_image(encoding):
|
|||
headers = {'user-agent': opts.api_useragent} if opts.api_useragent else {}
|
||||
response = requests.get(encoding, timeout=30, headers=headers)
|
||||
try:
|
||||
image = Image.open(BytesIO(response.content))
|
||||
image = images.apply_exif_orientation(image)
|
||||
image = images.read(BytesIO(response.content))
|
||||
return image
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail="Invalid image url") from e
|
||||
|
|
@ -94,8 +93,7 @@ def decode_base64_to_image(encoding):
|
|||
if encoding.startswith("data:image/"):
|
||||
encoding = encoding.split(";")[1].split(",")[1]
|
||||
try:
|
||||
image = Image.open(BytesIO(base64.b64decode(encoding)))
|
||||
image = images.apply_exif_orientation(image)
|
||||
image = images.read(BytesIO(base64.b64decode(encoding)))
|
||||
return image
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail="Invalid encoded image") from e
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue