Frontend for this project is here - https://github.com/samaranin/add-text-on-image-frontend
flask
uwsgi
nider
flask-cors
Clone the repository and create next folders
/repository
--/fonts
--/temp
--/sources
----/backgrounds
----/labels
...
all other code here
/fonts - folder for fonts
/temp - folder for processed images
/sources - folder for source images
--/backgrounds - images to place text on
--/labels - images to be attached to backgrounds (to left or right side)
1. /api/fonts/ - list of font files
2. /api/backgrounds/ - list of images to place text on
3. /api/labels/ - list of images to be attached to background
4. /sources/backgrounds/image.name - endpoint to show background image
5. /sources/labels/image.name - endpoint to show label image
6. /temp/image.name - endpoint to show ready image
7. /api/join_images/ - endpoint to join two images (both must be on server, label must be in sources/labels/)
a. GET method - returns JSON-error with text and example JSON-scheme
b. POST method - gets JSON
{
"text_image": "image_with_text",
"label_image": "label_image",
"join": "left" or "right"
}
and returns path to generated image
{"data": "temp/image.name"}
8. /api/write_text/ - endpoint to write text on images (image must be on server)
a. GET method - returns JSON-error with text and example JSON-scheme
b. POST method - gets JSON
{
"background_image": "image_to_write_text", // <- must be on server in sources/backgrounds
"header": "header",
"footer": "footer",
"width": "width",
"height": "height",
"header_font_name": "header_font_name", // <- must be on server in fonts/
"text_width_header": "text_width_header",
"font_size_header": "font_size_header",
"footer_font_name": "footer_font_name", // <- must be on server in fonts/
"text_width_footer": "text_width_footer",
"font_size_footer": "font_size_footer",
"top_padding": "top_padding",
"bottom_padding": "bottom_padding"
}
and returns path to generated image
{"data": "temp/image.name"}
9. /api/get_image_size/ - endpoint to get image width and height (must be in sources/labels/ or sources/backgrounds/)
a. GET method - returns JSON-error with text and example JSON-scheme
b. POST method - gets JSON
{
"image_type": "background or label",
"image_name": "name of image"
}
and returns path to generated image
{"widht": "image width", "height": "image height"}
10. /api/remove_temp_files/ - endpoint clear files in temp/ dir
To run the app use command
docker-compose up -d
and go to the localhost:5000