A simple meme generator exposed as a CLI, web app, and REST API. You can specify an image and a quote (the quote text and author) and you'll get back a meme composed of the quote layered over the image. See below for some sample memes generated from the command line 👇 👇
-
CLI - generate memes from the command line
- clone the github repo and cd into the
srcfolder inside the repo's folder - run
pip install -r requirements.txtto installs dependencies and setup the environment - run
python3 meme.pyto generate a random meme from our collection of images and quotes. You can also use the--quotesand--imagesto specify folders containing your collection of quotes and images to generate from. See the How It Works section for details on how the quotes files are to be structured if you plan to extend the system or provide custom quotes with the--quotesoption - run
python3 meme.py --body "nice quote" --author "Someone" --path "relative/path/to/img.jpg|jpeg|png|gif|..."to generate a meme using the provided image and quote body/author.
- clone the github repo and cd into the
-
Web App - generate memes on the web
- Go to https://turbo-meme-generator.onrender.com
- Click the Generate button to see randonly generated memes or use the Make Yours form to specify a quote and an image to generate a meme from
-
REST API
- Make a
GETrequest to https://turbo-meme-generator.onrender.com E.gcurl -H "Content-type: application/json" "https://turbo-meme-generator.onrender.com" - Make a
POSTrequest to https://turbo-meme-generator.onrender.com with a JSON body containing the quote, author and image URL like
curl -X POST "https://turbo-meme-generator.onrender.com/create" \ -H "Content-type: application/json" \ -d '{"image_url": "https://dailypost.ng/wp-content/uploads/2023/02/Peter-Obi.jpg", "body": "Vote mama, papa, pikin", "author": "Peter Obi"}'
Both the
POSTandGETrequests should return a response payload like{ "meme": "https://turbo-meme-generator.onrender.com/static/meme-image.jpg" } - Make a
Quotes files are simple files containing a quote per line. A line of quote is a simple text where the - character separates the text of the quote from the author. E.g a .txt or .pdf quotes file can have multiple lines like 👇 👇
People will never forget how you made them feel - Maya Angelou
Out of the box, supported quote file formats are .txt, .pdf, .csv, and .docx
Images from which to generate the memes can be any of the popular image formats. So far, we've tested with .jpg | jpeg, and .png, but I don't see why webp won't be supported 😁
Under the hood, the system uses a number of submodules to handle specific aspects of generating and serving memes.
- QuoteEngine Module - Uses a class heirarchy strutured after the strategy design pattern to handle parsing and reading of quotes from files. It's job is to return a list of
Quotesfrom supported files, or raise an exception if something goes wrong. It relies on some 3rd party libraries/tools (like python-docx and xpdf) to parse files
-
MemeEngine Module - Uses the Pillow library to generate memes. It draws a random quote on a random/provided image, which it returns as a meme with a max-height of
500px -
Entrypoints - Though not typical modules, meme.py and app.py aresrc entrypoints for generating and serving memes from the comand line and the web, respectively
-
Creat a
YAMLQuotesIngestorwithin thequoteenginemodule. It should extend and implement the abstractQuoteIngestorclass -
Add your new parser/ingestor into the
SmartIngestor- import it, e.g
from .yml_ingestor import YAMLQuotesIngestor as YAMLIngest - include the imported parser in the returned list in the
ingestors()method
@classmethod def ingestors(cls) -> List[QuoteIngestor]: return [..., YAMLIngest]
- import it, e.g
-
Add your YAML quotes file into the
src/_datafolder of the codebase and proceed to generate random memes, which should include quotes from your YAML file. Alternatively, run the meme generator with the--quotesoption pointing to a directory containing your YAML quotes file
- Remove the author delimeter character (i.e -) from quote bodies