An open API service indexing awesome lists of open source software.

https://github.com/jsonfm/fastapi-text-to-image

An API to convert a text message into an image with that message
https://github.com/jsonfm/fastapi-text-to-image

fastapi python

Last synced: about 2 months ago
JSON representation

An API to convert a text message into an image with that message

Awesome Lists containing this project

README

          

### Text To image API

convert a text string into an image with that string

### Code

```python
@app.post("/text-to-image", tags=["API"], response_model=TextToImageResponse)
def text_to_image_api(form: TextToImageForm, with_mime: bool = False):
image = text_to_image(
form.text,
font_size=form.font_size,
bg_color=form.bg_color,
font_color=form.font_color,
image_size=form.image_size,
)
if with_mime:
image = f"data:image/png;base64,{image}"
return {"image": image}
```

### Run

```
uvicorn main:app --host 0.0.0.0 --port 8080
```