How thomasatlantis/words2card works
Project type and purpose
• This is a small, single-purpose Python CLI tool (“Words2Card”) that takes user-supplied quotes (in JSON), overlays them on a cover image, and outputs a shareable picture card.
File structure
• Top-level files
– data.txt: a JSON array of quote objects (author, quotes, optional image URL/path)
– words2card.py: the core Python program orchestrating input→render→output
– netease_lyric.py: an auxiliary script (from the NeteaseLyric project) for fetching lyrics (optional integration)
• Directories
– image/: user-provided cover images used when a quote’s “image” field is empty
– output/: destination folder for generated card images
• Dependencies and config
– Python 3.x, PIL/Pillow (for image manipulation)
– No complex build or deployment scripts—just pip install Pillow
README for architectural hints
• Mentions optional remote image URLs and fallback to local images
Components
a. Main components
1. Input Data Store
• JSON file (data.txt)
• Optional NeteaseLyric API module (netease_lyric.py)
2. Resource Manager
• Local cover images (image/)
3. Card Generation Engine
• words2card.py (Python script using PIL)
• Layout & typography logic
4. Output Sink
• output/ directory (PNG files)
b. Relationships & Data Flow
• Engine → Output Sink (writes .png files)
• If network image URL provided: Engine → External HTTP Service → Engine
c. Architectural patterns & principles
• Pipeline pattern: a sequential flow of transform steps (parse → select resources → render → write)
• Single-responsibility modules: separation between data access (JSON/lyrics), rendering logic, and resource management
d. Key technologies
• Python 3.x, PIL/Pillow (image compositing)
• JSON parsing (built-in json module)
• Font rendering via .ttc file
• Optional HTTP client (for remote images or lyrics)