(
image: Float[Tensor, "3 height width"],
image_format: Literal["png", "jpeg"] = "png",
)
| 13 | |
| 14 | |
| 15 | def encode_image( |
| 16 | image: Float[Tensor, "3 height width"], |
| 17 | image_format: Literal["png", "jpeg"] = "png", |
| 18 | ) -> str: |
| 19 | stream = BytesIO() |
| 20 | Image.fromarray(prep_image(image)).save(stream, image_format) |
| 21 | stream.seek(0) |
| 22 | base64str = codecs.encode(stream.read(), "base64").rstrip() |
| 23 | return f"data:image/{image_format};base64,{base64str.decode('ascii')}" |
| 24 | |
| 25 | |
| 26 | def save_svg(fig: svg.SVG, path: Path) -> None: |
nothing calls this directly
no test coverage detected