From 2d7365178e070304decc63659a419b1ef51b1f10 Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Sat, 20 Jan 2024 22:02:40 +0800 Subject: [PATCH] fix: image encoding issue when the format is not specified (#4435) fix: give a default format when it's not specified Signed-off-by: Frost Ming --- src/_bentoml_sdk/validators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_bentoml_sdk/validators.py b/src/_bentoml_sdk/validators.py index c5b168b989c..09f1b209e13 100644 --- a/src/_bentoml_sdk/validators.py +++ b/src/_bentoml_sdk/validators.py @@ -76,7 +76,7 @@ def decode(self, obj: bytes | t.BinaryIO | UploadFile | PILImage.Image) -> t.Any def encode(self, obj: PILImage.Image) -> bytes: buffer = io.BytesIO() - obj.save(buffer, format=obj.format) + obj.save(buffer, format=obj.format or "PNG") return buffer.getvalue() def __get_pydantic_core_schema__(