diff --git a/backend/python/diffusers/backend.py b/backend/python/diffusers/backend.py index 00b292292..0299b9b4c 100755 --- a/backend/python/diffusers/backend.py +++ b/backend/python/diffusers/backend.py @@ -864,8 +864,13 @@ class BackendServicer(backend_pb2_grpc.BackendServicer): **kwargs ).images[0] - # save the result - image.save(request.dst) + # save the result. Save as PNG explicitly instead of letting Pillow + # infer the encoder from the extension: the core passes an absolute + # staging path ending in .tmp (e.g. /staging/localai-output-*.tmp), + # which Pillow can't map to a format and would raise + # "unknown file extension: .tmp". LocalAI serves generated images as + # PNG regardless of the temp path. + image.save(request.dst, format="PNG") return backend_pb2.Result(message="Media generated", success=True) diff --git a/backend/python/tinygrad/backend.py b/backend/python/tinygrad/backend.py index bb09e9e49..fa643568c 100644 --- a/backend/python/tinygrad/backend.py +++ b/backend/python/tinygrad/backend.py @@ -670,7 +670,10 @@ class BackendServicer(backend_pb2_grpc.BackendServicer): arr = img_tensor.numpy() image = Image.fromarray(arr) dst = request.dst or os.path.join(tempfile.gettempdir(), "tinygrad_image.png") - image.save(dst) + # Force PNG rather than letting Pillow guess from the extension: the + # core passes a staging path ending in .tmp, which Pillow can't map + # to a format ("unknown file extension: .tmp"). + image.save(dst, format="PNG") return backend_pb2.Result(success=True, message=dst) except Exception as exc: import traceback diff --git a/backend/python/vllm-omni/backend.py b/backend/python/vllm-omni/backend.py index e03c6c6d4..c0e47b25a 100644 --- a/backend/python/vllm-omni/backend.py +++ b/backend/python/vllm-omni/backend.py @@ -337,9 +337,11 @@ class BackendServicer(backend_pb2_grpc.BackendServicer): if not images or len(images) == 0: return backend_pb2.Result(success=False, message="Empty images list") - # Save image + # Save image. Force PNG rather than letting Pillow guess from the + # extension: the core passes a staging path ending in .tmp, which + # Pillow can't map to a format ("unknown file extension: .tmp"). output_image = images[0] - output_image.save(request.dst) + output_image.save(request.dst, format="PNG") return backend_pb2.Result(message="Image generated successfully", success=True) except Exception as err: