From 482cd357785d76c7758988fa3354c6aae3de3753 Mon Sep 17 00:00:00 2001 From: mrhan1993 <50648276+mrhan1993@users.noreply.github.com> Date: Fri, 22 Dec 2023 11:51:27 +0800 Subject: [PATCH] add support for base64 str like "data:image/png;base64,xxxxxx...." --- fooocusapi/img_utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fooocusapi/img_utils.py b/fooocusapi/img_utils.py index 912f509..3543b2d 100644 --- a/fooocusapi/img_utils.py +++ b/fooocusapi/img_utils.py @@ -36,6 +36,8 @@ def read_input_image(input_image: UploadFile) -> np.ndarray: return image def base64_to_stream(image: str) -> UploadFile: + if image.startswith('data:image'): + image = image.split(sep=',', maxsplit=1)[1] image_bytes = base64.b64decode(image) byte_stream = BytesIO() byte_stream.write(image_bytes)