Update README.md in Meme_Generator
This commit is contained in:
+59
-27
@@ -1,50 +1,82 @@
|
|||||||
## Meme Generator Project
|
## Meme Generator
|
||||||
|
|
||||||
### Overview
|
A Python application that combines an image with a quote to create a meme. It supports random or custom memes through a command-line interface and a small Flask web app.
|
||||||
The goal of this project is to build a "meme generator" – a multimedia application to dynamically generate memes, including an image with an overlaid quote.
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
### Set up environment
|
- Import quotes from CSV, DOCX, PDF, and TXT files.
|
||||||
```sh
|
- Resize images and overlay a quote and author.
|
||||||
$ sudo apt-get install -y xpdf
|
- Generate memes from bundled assets or user input.
|
||||||
$ pip install -r requirements.txt
|
- Use either the command line or a browser interface.
|
||||||
|
|
||||||
|
### Requirements
|
||||||
|
|
||||||
|
- Python 3
|
||||||
|
- Python packages in [`requirements.txt`](requirements.txt)
|
||||||
|
- Poppler's `pdftotext` command on `PATH` for PDF quote ingestion
|
||||||
|
|
||||||
|
### Setup
|
||||||
|
|
||||||
|
Run these commands from this project directory:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt-get install -y xpdf
|
||||||
|
sudo apt install python3-venv
|
||||||
|
python3 -m venv .venv
|
||||||
|
source .venv/bin/activate
|
||||||
|
python3 -m pip install -r requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run program
|
### Command Line
|
||||||
|
|
||||||
|
Generate a meme from a random bundled image and quote:
|
||||||
|
|
||||||
Python test \
|
|
||||||
Usage: `python3 meme.py --path [image_path] --body [quote_body] --author [quote_author]`
|
Usage: `python3 meme.py --path [image_path] --body [quote_body] --author [quote_author]`
|
||||||
```sh
|
|
||||||
$ mkdir tmp
|
```bash
|
||||||
$ python3 meme.py
|
mkdir -p tmp
|
||||||
|
python3 meme.py
|
||||||
|
|
||||||
|
python3 meme.py \
|
||||||
|
--path ./_data/photos/dog/xander_1.jpg \
|
||||||
|
--body "Stay pawsitive." \
|
||||||
|
--author "Unknown"
|
||||||
```
|
```
|
||||||
|
|
||||||
Flask test
|
### Web App
|
||||||
```sh
|
|
||||||
$ mkdir static
|
```bash
|
||||||
$ python3 app.py
|
mkdir -p static
|
||||||
|
python3 app.py
|
||||||
```
|
```
|
||||||
Open link `http://127.0.0.1:5000` in web browser
|
|
||||||
|
|
||||||
### Primary modules
|
Open [http://127.0.0.1:5000](http://127.0.0.1:5000) for a random meme or use the `/create` page to submit an image URL and quote. Generated web images are saved in `static/`.
|
||||||
|
|
||||||
`QuoteEngine`: Meme engine module for handling the generation of meme images.\
|
<a href="url"><img src="./images/random.png" width="500"></a>
|
||||||
`MemeEngine`: QuoteModel module for representing a quote with its body and author.
|
|
||||||
|
|
||||||
### Sub modules
|
<a href="url"><img src="./images/creator.png" width="500"></a>
|
||||||
|
|
||||||
`CSVIngestor`: Module for ingesting CSV files containing quotes. \
|
### Project Structure
|
||||||
`DocxIngestor`: Module for ingesting Docx files containing quotes. \
|
|
||||||
`TextIngestor`: Module for ingesting text files containing quotes. \
|
- [`meme.py`](meme.py) — Command-line entry point for generating random or custom memes.
|
||||||
`PDFIngestor`: Module for ingesting PDF files containing quotes.
|
- [`app.py`](app.py) — Flask web application for creating memes in a browser.
|
||||||
|
- [`MemeEngine/`](MemeEngine/) — Resizes images, positions quote text, and saves generated memes.
|
||||||
|
- [`QuoteEngine/`](QuoteEngine/) — Represents quotes and imports them from supported file formats.
|
||||||
|
- `QuoteModel` — Stores a quote's body and author.
|
||||||
|
- `Ingestor` — Selects the appropriate file-format parser.
|
||||||
|
- `CSVIngestor` — Imports quotes from CSV files.
|
||||||
|
- `DocxIngestor` — Imports quotes from DOCX files.
|
||||||
|
- `PDFIngestor` — Imports quotes from PDF files.
|
||||||
|
- `TextIngestor` — Imports quotes from TXT files.
|
||||||
|
- [`templates/`](templates/) — HTML templates used by the Flask application.
|
||||||
|
- [`_data/`](_data/) — Sample images, quotes, and font assets.
|
||||||
|
|
||||||
### Format checking
|
### Format checking
|
||||||
```sh
|
```bash
|
||||||
$ pip install docformatter
|
$ pip install docformatter
|
||||||
$ pip install autopep8
|
$ pip install autopep8
|
||||||
$ pip install black
|
$ pip install black
|
||||||
$ pip install flake8
|
$ pip install flake8
|
||||||
|
|
||||||
$ docformatter -i -r --wrap-summaries 79 --wrap-descriptions 79 .
|
$ docformatter -i -r --wrap-summaries 79 --wrap-descriptions 79 .
|
||||||
$ autopep8 --in-place --recursive --aggressive .
|
$ autopep8 --in-place --recursive --aggressive .
|
||||||
$ black .
|
$ black .
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 241 KiB |
@@ -20,7 +20,7 @@ def generate_meme(path=None, body=None, author=None):
|
|||||||
|
|
||||||
img = random.choice(imgs)
|
img = random.choice(imgs)
|
||||||
else:
|
else:
|
||||||
img = path[0]
|
img = path
|
||||||
|
|
||||||
if body is None:
|
if body is None:
|
||||||
quote_files = [
|
quote_files = [
|
||||||
|
|||||||
Reference in New Issue
Block a user