<picture>
  <source media="(prefers-color-scheme: dark)" srcset="/projects/readme/quotecard/docs-banner-dark.webp">
  <img src="/projects/readme/quotecard/docs-banner-light.webp" alt="quotecard" width="760" height="215" loading="lazy" decoding="async">
</picture>
<img src="/projects/readme/quotecard/docs-hero.webp" width="1432" height="443" alt="Four cards rendered by quotecard: an X post, a Substack note, a Substack article, and a typed line" loading="lazy" decoding="async">

## Install

```bash
pip install git+https://github.com/HighnessAtharva/quotecard.git
```

```bash
playwright install chromium
```

```bash
quotecard init --name "Your Name" --handle yourhandle --avatar photo.png
```

Chromium does the rendering and installs once, about 150 MB. `init` stores your identity, so plain text always comes out with your face on it. Then cache the fonts, which makes every later render offline and identical on any machine:

```bash
quotecard fonts
```

Check the whole setup in one command:

```bash
quotecard doctor
```

---

## Thirty seconds

```bash
quotecard https://x.com/username/status/1234567890
```

```bash
quotecard "the line I want on a card" --look editorial-cream --size 1:1
```

```bash
quotecard -f links.txt -d cards/ --look dark --size 4:5,9:16
```

Cards land as 1080-pixel PNGs in the current directory. Send them elsewhere with `-d cards/`, or name one file with `-o card.png`. Add `--open` to pop the result straight into your image viewer.

---

## Eight looks

Run `quotecard looks --render` to make this sheet yourself, with your own words and your own face on it.

|  |  |  |  |
|:--:|:--:|:--:|:--:|
| <img src="/projects/readme/quotecard/docs-looks-light.png" width="200" alt="light" height="200" loading="lazy" decoding="async"><br>`light` | <img src="/projects/readme/quotecard/docs-looks-dark.png" width="200" alt="dark" height="200" loading="lazy" decoding="async"><br>`dark` | <img src="/projects/readme/quotecard/docs-looks-serif-light.png" width="200" alt="serif-light" height="200" loading="lazy" decoding="async"><br>`serif-light` | <img src="/projects/readme/quotecard/docs-looks-serif-dark.png" width="200" alt="serif-dark" height="200" loading="lazy" decoding="async"><br>`serif-dark` |
| <img src="/projects/readme/quotecard/docs-looks-editorial-cream.png" width="200" alt="editorial-cream" height="200" loading="lazy" decoding="async"><br>`editorial-cream` | <img src="/projects/readme/quotecard/docs-looks-editorial-dark.png" width="200" alt="editorial-dark" height="200" loading="lazy" decoding="async"><br>`editorial-dark` | <img src="/projects/readme/quotecard/docs-looks-rounded-light.png" width="200" alt="rounded-light" height="200" loading="lazy" decoding="async"><br>`rounded-light` | <img src="/projects/readme/quotecard/docs-looks-rounded-dark.png" width="200" alt="rounded-dark" height="200" loading="lazy" decoding="async"><br>`rounded-dark` |

---

## Five sizes

| <img src="/projects/readme/quotecard/docs-ex-size-45.png" width="215" alt="portrait 4:5" height="269" loading="lazy" decoding="async"> | <img src="/projects/readme/quotecard/docs-ex-size-11.png" width="240" alt="square 1:1" height="240" loading="lazy" decoding="async"> | <img src="/projects/readme/quotecard/docs-ex-size-916.png" width="140" alt="story 9:16" height="249" loading="lazy" decoding="async"> |
|:--:|:--:|:--:|
| **`4:5`** 1080x1350<br>Instagram and LinkedIn | **`1:1`** 1080x1080<br>square feeds | **`9:16`** 1080x1920<br>Stories, Reels, TikTok |

`16:9` and `3:4` are there too, and any explicit `--size 1200x1200` works. A story is a poster rather than a screenshot, so the text grows to fill it while a feed card keeps its chosen size.

---

## What it reads

| Paste this | quotecard pulls |
|---|---|
| `x.com/user/status/123` | text, name, handle, profile photo, verified badge, live counts |
| `substack.com/@user/note/c-123` | text, name, handle, profile photo, likes, restacks, replies |
| `yourblog.substack.com/p/slug` and custom Substack domains | title, subtitle, byline, photo |
| `threads.net/@user/post/CODE` | text, name, handle, profile photo |
| anything that is not a URL | your own words, with your identity |

`twitter.com`, `mobile.x.com`, `fxtwitter.com` and `vxtwitter.com` all resolve to the same X post.

X truncates a long post at 280 characters through its public endpoint. quotecard notices and fills in the full body from a public mirror, so a long post renders whole.

---

## Recipes

| Command | You get |
|---|:--:|
| `quotecard https://x.com/harsehaj/status/2092101159032930616` | <img src="/projects/readme/quotecard/docs-ex-src-x.png" width="150" alt="an X post as a card" height="188" loading="lazy" decoding="async"> |
| `quotecard https://substack.com/@a16z/note/c-321561696 --look dark` | <img src="/projects/readme/quotecard/docs-ex-src-note.png" width="150" alt="a Substack note as a card" height="188" loading="lazy" decoding="async"> |
| `quotecard https://blog.example.com/p/a-post --look serif-light` | <img src="/projects/readme/quotecard/docs-ex-src-article.png" width="150" alt="a Substack article as a card" height="188" loading="lazy" decoding="async"> |
| `quotecard "writing is thinking." --format text --quote-mark`<br>`  --look editorial-cream` | <img src="/projects/readme/quotecard/docs-ex-src-text.png" width="150" alt="a typed line as a text-only card" height="188" loading="lazy" decoding="async"> |

More, without pictures:

```bash
# every look at once, then pick the winner
quotecard https://x.com/user/status/123 --all-looks -d cards/

# a story and a feed card from one link
quotecard https://x.com/user/status/123 --size 9:16,4:5 -d cards/

# fix a typo, drop the counts, add your site in the footer
quotecard https://x.com/user/status/123 \
  --text "the corrected line" --no-engagement --watermark "yoursite.com"

# a long quote out of a file, newlines kept
quotecard placeholder --text-file quote.txt --format text --look serif-dark

# print-ready, 2160 pixels wide
quotecard "a line" --scale 2 --size 1:1
```

---

## Whose face goes on the card

Pick one of three modes in config, then override it per run.

| Mode | Behavior |
|---|---|
| `auto` (default) | your identity on your own text and on posts under one of your handles, the real author on everybody else's |
| `always-me` | your identity on every card |
| `source` | the real author every time |

```bash
quotecard init --alias yoursubstack --alias yourgithub
quotecard config --set identity=always-me
quotecard https://x.com/someone/status/123 --me
```

Attribution matters, so `auto` keeps a stranger's name and face on a stranger's words. When a source gives no photo, your picture fills the slot instead of leaving a hole.

---

## Batch

One link or one line of text per line. Blank lines and `#` comments are ignored.

```bash
quotecard -f links.txt -d cards/ --look dark --size 4:5,9:16 --json
```

Every link is read at the same time, a repeated link is read once, and one browser renders the whole file. Twelve cards from nine links take about six seconds. Tune the pool with `--jobs`, which defaults to 8.

Cards that already exist are skipped. Pass `--overwrite` to replace them.

---

## For agents and scripts

`--json` prints one object per card on stdout. Nothing else goes to stdout, so the stream stays parseable.

```json
{"input":"https://x.com/...","ok":true,"path":"cards/x-user-123.png","width":1080,"height":1350,"look":"light","font_size":57.6,"source":"x","author":"harsehaj","handle":"harsehaj","text":"...","url":"https://x.com/..."}
```

Exit codes: `0` every card worked, `1` nothing worked, `2` some worked and some failed. A failed link never stops the batch, so read `ok` per line.

```bash
quotecard fetch https://x.com/user/status/123   # read a post, render nothing
quotecard -f links.txt --dry-run --json         # plan a batch, no browser
```

A card whose text hit the minimum size carries `"warning"`. Move that post to `--size 9:16` or split it, and never ship it clipped.

---

## Every option

```
quotecard [inputs...] [options]

  -f, --from-file FILE   one URL or line of text per line
  -o, --out FILE         exact output path, for a single card
  -d, --out-dir DIR      where the PNGs land

  --look NAME            comma separated, or --all-looks
  --size SPEC            comma separated, named or WxH
  --text-size SIZE       small, medium, large, xl
  --format card|text     card keeps the header, text drops it
  --align top|center|bottom
  --fit auto|shrink|fill
  --scale N              2 renders at 2160 pixels wide
  --pad PX               canvas around the card, 0 fills the frame
  --quote-mark           open with a large quotation mark
  --watermark TEXT       small footer text on the right
  --avatar-shape circle|square

  --text TEXT            replace the fetched text
  --text-file FILE       read the card text from a file
  --title TEXT           bold line above the body
  --name, --handle, --avatar
  --me                   force your identity onto every card
  --identity MODE        auto, always-me, source
  --no-engagement        hide the counts
  --no-verified          hide the badge
  --likes N, --reposts N, --replies N

  --jobs N               parallel fetches, default 8
  --offline              block all network during render
  --overwrite            replace PNGs that already exist
  --dry-run              fetch and plan, render nothing
  --open                 open each finished card
  --json                 one JSON object per card
  -q, --quiet
```

| Subcommand | What it does |
|---|---|
| `init` | store your name, handle and profile picture |
| `config` | show or change stored defaults |
| `fonts` | cache the webfonts for offline, identical renders |
| `looks` | list every look, or `--render` a sample of each |
| `fetch` | read a post and print it as JSON |
| `doctor` | check config, fonts, Chromium and the network |

---

## How it works

Four readers hand back one shape, and one Chromium renders it.

- **X** goes through the public syndication endpoint behind every embedded tweet. No key, no login.
- **Substack** notes come from the public reader endpoint, and articles from the publication's own posts API, custom domains included.
- **Threads** serves an empty page to a plain HTTP client, so the same Chromium that draws the card reads the post.
- **Text** skips the network.

The card is one HTML file. The text auto-fits by binary search, so a 2,000 character post shrinks until it fits and a six word line grows to fill a story.

Speed comes from four choices. Every link in a batch is read at once. One browser and one page serve the whole run. Avatars download once and are cached. The fonts live on disk, so the render never waits on a request.

---

## Config

`quotecard config --path` prints the file. `QUOTECARD_HOME` moves the whole directory.

| Key | Default | Meaning |
|---|---|---|
| `name`, `handle`, `avatar` | empty | your identity |
| `verified` | `false` | show a badge on your cards |
| `identity` | `auto` | auto, always-me, source |
| `aliases` | empty | other handles that are you |
| `look`, `size`, `text_size`, `format` | `light`, `4:5`, `large`, `card` | defaults for every run |
| `engagement` | `true` | show counts when the source has them |
| `out_dir` | `.` | where PNGs land |

```bash
quotecard config --set look=dark --set size=1:1
```

---

## Tests

```bash
pip install -e ".[dev]" && pytest
```

147 tests. Parsing runs off saved API payloads, so most of the suite needs no network. `pytest -m "not render"` skips the tests that start Chromium.

---

## Limits

- Threads needs Chromium to read a post, which is slower than the other three, and Threads gives no engagement counts.
- A protected, deleted, or age-gated X post cannot be read. The error says so.
- X's public endpoint carries no repost count, so an X card shows likes and replies.
- Images and video inside a post are not drawn. The card carries the words.

---

## License

The license is MIT. Built by [Atharva Shah](https://atharvashah.com).

