Creates images from text input received through HTTP requests
648
This is a Python script that creates images from text input received through HTTP requests.
docker-compose.yaml file:services:
placeholder_service:
image: bkbillybk/placeholder_service
restart: unless-stopped
ports:
- 9845:9845
docker compose -f docker-compose.yaml up
This will start the server on http://localhost:9845 by default.
You can use any tool that can send HTTP requests, such as curl or a web browser. Here's an example using curl:
curl "http://localhost:9845/?text=YOUR_TEXT&font=FONT_NAME.ttf&color_text=COLOR_CODE&color_bg=COLOR_CODE&font_size=SIZE&font_align=ALIGN&img_format=FORMAT"
# Replace with your desired options:
# - text: The text to be displayed on the image (required)
# - font: Path to a font file (optional, defaults to 'FrederickatheGreat-Regular.ttf')
# - color_text: Text color in hex code (e.g., 'FF0000' for red, optional, defaults to '1400FF')
# - color_bg: Background color name or hex code (optional, defaults to 'white')
# - font_size: Font size in pixels (optional, defaults to 200)
# - font_align: Horizontal text alignment ('left', 'center', or 'right', optional, defaults to 'center')
# - img_format: Image format (e.g., 'png', 'jpg', etc., optional, defaults to 'png')
curl "http://localhost:9845/?text=Hello\nWorld!&color_text=00FF00&color_bg=0000FF"
This will download an image with the text "Hello\nWorld!" in green color and in blue background.
By default, the server tries to download fonts from the Google Fonts repository if the requested font is not found locally. This functionality requires an internet connection.
The script uses Python's built-in logging module. You can configure logging behavior by creating a separate logging configuration file.
Feel free to modify the script to suit your specific needs. You can add functionalities like:
This project is licensed under the MIT License. See the LICENSE file for details.
Content type
Image
Digest
sha256:e691676e4…
Size
132.9 MB
Last updated
about 2 years ago
docker pull bkbillybk/placeholder_service