mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-25 01:09:22 +01:00
API: Properly handle Images with RGBA color format (#5332)
This commit is contained in:
parent
db1da9f98d
commit
166fdf09f3
@ -156,8 +156,9 @@ def convert_history(history):
|
||||
img = Image.open(BytesIO(my_res.content))
|
||||
except Exception:
|
||||
raise 'Image cannot be loaded from the URL!'
|
||||
|
||||
buffered = BytesIO()
|
||||
if img.mode in ("RGBA", "P"):
|
||||
img = img.convert("RGB")
|
||||
img.save(buffered, format="JPEG")
|
||||
img_str = base64.b64encode(buffered.getvalue()).decode('utf-8')
|
||||
content = f'<img src="data:image/jpeg;base64,{img_str}">'
|
||||
|
Loading…
Reference in New Issue
Block a user