This is a local web app for generating two-layer poem images from your existing excerpt resources.
- Preserves the poem text exactly as entered
- Searches local sources:
- excerpt library runtime DB
- Weaver approved / QI-ready excerpts
- curated short-poems catalog export
- Lets you change font, weight, size, line height, alignment, and inset
- Supports two layout modes:
- preserve line breaks with wrap
- paragraph flow
- Generates simple backgrounds:
- solid
- gradient
- stripes
- dots
- Can generate AI backgrounds through OpenAI while keeping the text layer deterministic
- Exports the result as a PNG
Start the local app server from the poem-image-generator folder.
You can provide your OpenAI key in either of these ways:
export OPENAI_API_KEY=your_key_hereor create poem-image-generator/.env with:
OPENAI_API_KEY=your_key_hereThen run:
python3 api_server.pyThen open http://127.0.0.1:8123.
To use Save to Drive and Send to Weaver, add these environment variables before starting the server:
GOOGLE_OAUTH_CLIENT_ID=your_google_oauth_client_id
GOOGLE_API_KEY=your_google_api_key
GOOGLE_APP_ID=your_google_project_numberThe Drive flow uses browser-based Google sign-in plus a folder picker, uploads the current PNG to the selected Drive folder, then posts the resulting asset URLs to Weaver QC.
P.I.G. is now prepared for container hosting without changing the local workflow.
api_server.pywill still default to127.0.0.1:8123locally- if a hosting platform provides
PORT, the server will listen on that port - if
PORTis present, the server will default to0.0.0.0 - a basic health check is available at
/api/health - environment-aware app config is available at
/api/app-config - a production-ready container file is included in Dockerfile
- a first-pass Cloud Run deploy helper is included in deploy-cloud-run.sh
You can build and run the container locally with:
docker build -t pig-app .
docker run --rm -p 8080:8080 --env-file .env pig-appThen open http://127.0.0.1:8080.
Important note:
- the live Weaver graphics-request and completion flow is cloud-friendly now
- local excerpt DB/search sources still depend on files outside this folder unless you provide cloud-accessible replacements through these env vars:
PIG_EXCERPT_RUNTIME_DBPIG_QI_STATUS_DBPIG_NORMALIZED_EXCERPT_DBPIG_SHORT_POEMS_JSONPIG_FORMAL_CATALOG_DB
- in a hosted environment, the app now marks unavailable local-only sources as unavailable instead of pretending they exist
Example Cloud Run deploy:
cd poem-image-generator
chmod +x deploy-cloud-run.sh
PROJECT_ID=poetry-image-generator REGION=us-central1 SERVICE_NAME=pig ./deploy-cloud-run.shP.I.G. is now intended to live in its own Git repo from this folder. Secrets and local runtime artifacts are intentionally ignored:
.envstays local and should never be committed.data/*.dbfiles are runtime data bundles, not normal Git files. One local DB is larger than GitHub's standard per-file limit, so use Git LFS or move the data source to cloud storage before expecting a fresh clone to be fully self-contained.data/book_author_map.jsonanddata/full-poems-120-or-less-v74.jsonare small enough to track as bundled app data.
- Add custom font upload support.
- Add source-specific filters such as author, release catalog, and excerpt length.
- Add saved prompt presets for different background styles.
- Improve QI-library-driven template tuning.
- Background photos can now be imported directly into P.I.G.
- Imported or generated bitmap backgrounds can now be saved into a small reusable in-browser background library.
- The default hosted Drive flow now uploads through the Cloud Run service account when using the configured default Shared Drive folder.
Background options primer:
These are the unresolved items we parked at the end of the April 21, 2026 session.
-
Re-check title color rendering in hosted P.I.G. The title color picker and rendered output still do not feel fully trustworthy in all cases, especially when auto-contrast is active on mixed dark/light backgrounds.
-
Repair already-broken transparent PNGs in Drive. New exports are now flattened correctly, but older broken files in the dev Drive folder still need either:
- exact re-export from a surviving project snapshot, or
- approximate repair by flattening transparency onto a chosen background.
-
Audit whether any broken Drive exports still have recoverable exact snapshots. We confirmed which Drive files are broken, but did not find a clear surviving hosted snapshot for them yet. If the original browser/session still has those projects, some may still be exact-recoverable.
-
Decide on the repair approach for the currently broken Drive files. Current broken set identified:
WAKEFIELD - SWTWOB - QUOTE IMAGE - MY POINT FOREVER ENDLESSLYBELLA - WTF - QUOTE IMAGE - WHALE X TEARDROPTRAN - AEO - QUOTE IMAGE - CONFUCIUS WAS NOT A FEMINISTwhale x teardrop.png
- Keep
pig.buttonpoetry.comas a deferred infrastructure item. Hosted Cloud Run is working at therun.appURL, but the custom domain is still blocked by DNS/certificate routing issues and is intentionally paused for now.