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
- Host: GitHub
- URL: https://github.com/jsonfm/fastapi-text-to-image
- Owner: jsonfm
- Created: 2024-05-01T15:13:55.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-01T19:59:44.000Z (about 2 years ago)
- Last Synced: 2025-03-25T13:46:56.059Z (about 1 year ago)
- Topics: fastapi, python
- Language: Python
- Homepage: https://fastapi-text-to-image.vercel.app
- Size: 106 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
```