gleaner pulls every image out of a Google Doc or a slide deck (PowerPoint, Keynote or Google Slides, saved as .pptx). It handles two kinds:
| Kind | Where it lives | What gleaner does |
|---|---|---|
| Embedded | Pasted into the doc | Copies it out of the export and renames it by the heading and table row it sits under |
| Embedded, in a deck | Placed on a slide, or on the slide master | Copies it out of the deck and renames it by the slide number and title |
| Linked | Behind a URL in the text, a comment, or a slide’s speaker notes | Works out where the actual file is and downloads it |
It was built for media trackers: long tables of script lines, reference images, finished graphics, and links to Wikimedia, Pexels, Flickr and museum collections. A Google Docs export hands you the pasted images as image1.png to image67.png, with nothing to say which video or script line each one belongs to. The links are worse: thirty of them, each to be opened, chased to the real file and saved by hand. gleaner does both in one run and writes a spreadsheet that ties every file back to its place in the doc.
It reads the doc or deck and writes into a new folder. It never changes the doc, the export or the deck.
1. Install and update
The source is a Python package at ~/Developer/gleaner (its GitHub repo is private: ask Rafa for access). It needs Python 3.9 or newer; check with python3 --version. Install it as an editable package, so changes to the code take effect without reinstalling:
git clone https://github.com/rafabenedetti/gleaner.git ~/Developer/gleaner # skip if it's already there
pip3 install -e ~/Developer/gleaner
Check it from any folder:
gleaner --version # gleaner 0.2.0
If you get command not found and you use pyenv, run pyenv rehash and try again. python3 -m gleaner always works in place of gleaner.
To update: cd ~/Developer/gleaner && git pull. Because the install is editable, that’s all. To run the tests: pip3 install -e ".[test]" once, then python3 -m pytest. They run offline against a small made-up doc and decks the tests build themselves.
To uninstall: pip3 uninstall gleaner.
2. Getting the file out
A Google Doc
In the doc, choose File › Download › Web page (.html, zipped). A .zip lands in Downloads. You don’t need to unzip it.
The zip holds the doc as one .html file plus an images/ folder with every pasted image at the size it was uploaded, not the size it’s shown at. That’s why gleaner works from the export and not from the doc on screen: the originals are already in there.
If the doc is shared as Anyone with the link can view, you can skip this step and hand gleaner the doc’s link. For a private doc, download the zip.
A slide deck
gleaner reads .pptx files (and .ppsx and .potx, which are the same inside).
| Made in | What to do |
|---|---|
| PowerPoint | Use the .pptx as it is |
| Keynote | File › Export To › PowerPoint, then use that .pptx. gleaner can’t read .key files |
| Google Slides | File › Download › Microsoft PowerPoint (.pptx). If the deck is shared as Anyone with the link can view, you can hand gleaner the link instead |
3. Running it
usage: gleaner [-o OUT] [-n] [--large PX] [--no-embedded] [--no-links] [--no-previews] [--contact EMAIL] source
The source can be the zip, the unzipped folder, the .html inside it, a doc link, a .pptx, or a Slides link. Put quotes around any path with spaces or an &.
| Command | Result |
|---|---|
gleaner ~/Downloads/"My Doc.zip" --dry-run | Lists every image and link it found, the heading and row each sits under, and how it will fetch each one. Downloads nothing |
gleaner ~/Downloads/"My Doc.zip" | Everything, into My Doc (gleaned) beside the zip |
gleaner ~/Downloads/"My Doc" | Same, from an unzipped folder; output goes into a gleaned folder inside it |
gleaner "https://docs.google.com/document/d/…/edit" | Downloads the doc first (link-shared docs only); output goes into the current folder |
gleaner ~/Downloads/"My Deck.pptx" | Every image in the deck, named by slide, into My Deck (gleaned) beside it |
gleaner "https://docs.google.com/presentation/d/…/edit" | Downloads the deck first (link-shared decks only); output goes into the current folder |
gleaner "My Doc.zip" --large 1500 | Embedded images shown 1500 px wide or more go into large/, the rest into images/ |
gleaner "My Doc.zip" --no-links | Embedded images only. Needs no internet |
gleaner "My Doc.zip" --no-embedded | Linked images only |
gleaner "My Doc.zip" -o ~/Desktop/refs | Output into a folder you choose |
Always do the dry run first on a new doc or deck. It’s instant, and it shows whether the headings and row labels gleaner picked up are the ones you’d use to find things.
--large exists for trackers. In the Media Tracker, finished graphics are pasted big (1930 to 3840 px wide) and references small (under 600). Sorting on display width splits them cleanly. Most ordinary docs don’t need it.
--contact you@example.com adds your address to the identifier gleaner sends to websites. Wikimedia asks scripts to include one, and it can help if they rate-limit you.
The exit code is 0 when the run finished, even if some links failed (the manifest says which), and 2 when gleaner couldn’t open the source or the options were wrong.
Running it again is safe and useful. Embedded images are copied fresh. Links that already downloaded are skipped, so a second run only fetches what failed or was rate-limited the first time.
Shortcut: type gleaner with a trailing space, then drag the zip from Finder into Terminal to paste its path.
4. What comes out
My Doc (gleaned)/
├── images/ embedded images, renamed
├── large/ embedded images shown big (only with --large)
├── linked/ images downloaded from links
├── manifest.csv one row per image or link
└── open-by-hand.html links that need a person (only if there are any)
File names. Each name is the position in the doc, the nearest heading, the table row’s first-column label, and the original name:
052_DTC-Graphics-Jon-Campbell_113-Using-AI-Thoughtfully-in-Practice-Sc_image55.png
The number keeps files in document order in Finder. The row label carries down when a title cell spans several rows, the way a video title does in a tracker, so every image under a video gets its title. A heading inside a table row (a section header like “DTC Graphics: Jon Campbell”) starts a new section. An image used in several places is copied once, numbered by where it first appears; the manifest says how many times it’s used.
Deck file names. In a deck the heading is the slide number and the slide’s title, and there’s no row label. Slide numbers follow the order PowerPoint or Keynote shows, even after slides have been moved around. From a real run:
003_Slide-8-The-Right-Idea_image45.png
A slide with no title gives just Slide-8. Images that sit on the slide master or a layout (logos, background art behind every slide) come after all the slides, under Slide master or Layout: <layout name>. A deck with several masters numbers them: Slide master 3. Cropped images are saved whole, and the manifest says so.
manifest.csv opens in Numbers or Excel:
| Column | Meaning |
|---|---|
order | Position in the doc or deck |
kind | embedded or link, or media for a video or audio file in a deck |
where | body, or comment for a link typed into a comment. A comment link is placed at the text the comment is attached to, so it gets the right heading and row. In a deck, notes for a link in a slide’s speaker notes |
heading, row | Nearest heading; first-column label of the table row. In a deck, heading is Slide 8: The Right Idea (or Slide master, Layout: …) and row is empty |
nearby_text | A little of the surrounding text, for finding it in the doc |
source | images/imageN.png (ppt/media/imageN.png in a deck), or the link |
method | How it was fetched: wikimedia, google drive, dropbox, pexels, unsplash, direct, or page |
status | What happened (below) |
saved_as | The file, relative to the output folder |
note | Why it failed, or what to check |
| Status | Meaning |
|---|---|
saved | Got the real file |
preview | Got the page’s preview image, which may be smaller than the original. The file name ends in PREVIEW |
rate-limited | The site asked gleaner to slow down. Run again later |
page | A web page with no image gleaner could take. It’s in open-by-hand.html |
failed | A login wall, a blocked script, a dead link, or a Drive file that isn’t shared. Also in open-by-hand.html |
missing | The doc points to an image that isn’t in the export’s images/ folder |
skipped | A video or audio file in a deck. Listed so you know it’s there, but not copied |
open-by-hand.html is a clickable list of the links gleaner couldn’t turn into a file, with the heading, row and reason for each. Open it in a browser and work down the list.
5. How it fetches links
Google wraps every link in an export inside a google.com/url?q= redirect; gleaner strips that first. It also finds bare URLs typed into the text and into comments, which are easy to miss by eye. Links to other Google Docs, Sheets and Slides are skipped, since they’re documents and not images. Then each link goes the shortest way to the file. Links on slides and in speaker notes go through the same steps:
| Link | How |
|---|---|
Wikimedia Commons, or a Wikipedia …#/media/File:… link | Asks the Commons API for the original file. One request covers up to 50 titles |
| Google Drive file | The direct-download address, which also gets past Drive’s virus-scan page on large files |
| Dropbox | Switches dl=0 to dl=1 |
| Pexels or Unsplash photo page | Builds the full-size image address from the photo’s ID |
| A URL ending in an image extension | Downloads it as is |
| Any other page | Saves the preview image the page offers to Slack and iMessage, tagged PREVIEW |
Previews are the fallback, and their size varies: 512 px for a Noun Project icon, 1024 px for Flickr, about 1000 px for a DVIDS photo. Check them before they go into a final graphic, and check the license too. gleaner downloads what a link points to; it doesn’t check whether you’re allowed to use it.
It checks the bytes of every download, so a login page or an error page is never saved as a broken .jpg.
It’s polite by design. It waits about a second between requests to the same site, and two seconds for Wikimedia’s image server. When a site says “slow down”, gleaner waits and retries three times. If the site still refuses, gleaner leaves it alone for the rest of the run, marks its links rate-limited, and moves on. It doesn’t sit there for ten minutes.
On the Problem Solving & AI Media Tracker (86 image placements, 30 links), one run gave 67 embedded images (25 finished graphics in large/) and 26 of the 30 links. Twelve of those were previews: nine Noun Project icons, two Flickr photos and a DVIDS photo. The four left for a person were the National Archives record, a Google Patents page, and two Science Museum object pages, which block scripts.
6. Troubleshooting
| Symptom | Fix |
|---|---|
command not found: gleaner | Run pyenv rehash, or use python3 -m gleaner. If neither works, re-run pip3 install -e ~/Developer/gleaner |
can't open file … grab_tracker_media.py | That’s the old one-off script. Use gleaner |
Couldn't download that doc. It's probably private. | Only link-shared docs can be fetched by URL. Download the zip (section 2) and pass that |
More than one .html file in … | The folder holds two exports. Pass the .html you want, or the zip |
Lots of rate-limited rows | Wait ten minutes and run the same command again; finished files are skipped. For Wikimedia, add --contact |
A Drive link failed: “probably isn’t shared” | Drive sent a sign-in page. Share the file as Anyone with the link, or download it yourself |
A PREVIEW file is too small | Open its source link from the manifest and download the full size from the site. Flickr and most museums keep larger sizes behind a download button |
missing rows | The zip was only partly extracted. Pass the .zip itself |
| Headings or row labels look wrong in the dry run | gleaner uses real headings (Heading 1 to 6 in Docs) and the first column of each table. Bold text styled to look like a heading isn’t one. Apply a heading style in the doc and export again |
is a Keynote file, which gleaner can't read | In Keynote, choose File › Export To › PowerPoint and pass the .pptx |
Couldn't download that deck. It's probably private. | Share the deck as Anyone with the link, or download the .pptx (section 2) and pass that |
| Slide numbers don’t match PowerPoint | The deck is probably a .ppsx or .potx saved in an unusual way. Send it to Rafa |
An .emf or .wmf file won’t open | These are old PowerPoint vector drawings. Open them in Preview, or drag them into Keynote |
Nothing under linked/ at all | You’re offline, or you passed --no-links |