Skip to content

Commit

Permalink
add support for base64 str like "data:image/png;base64,xxxxxx...."
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhan1993 committed Dec 22, 2023
1 parent d10012b commit 482cd35
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fooocusapi/img_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 482cd35

Please sign in to comment.