Skip to content

Commit

Permalink
Merge pull request #105 from mrhan1993/main
Browse files Browse the repository at this point in the history
add support for base64 str like "data:image/png;base64,xxxxxx...." in v2 endpoint
  • Loading branch information
konieshadow authored Dec 22, 2023
2 parents d10012b + 482cd35 commit 49639d6
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 49639d6

Please sign in to comment.