rb · guides
rafabenedetti.com
user guides · 2026
Reference · User guide

gleaner: user guide

A Python command that pulls every image out of a Google Doc or a slide deck, the ones pasted into it and the ones it links to, and names each file by where it sits. Install, export, run, what comes out, and fixes.

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:

KindWhere it livesWhat gleaner does
EmbeddedPasted into the docCopies it out of the export and renames it by the heading and table row it sits under
Embedded, in a deckPlaced on a slide, or on the slide masterCopies it out of the deck and renames it by the slide number and title
LinkedBehind a URL in the text, a comment, or a slide’s speaker notesWorks 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 inWhat to do
PowerPointUse the .pptx as it is
KeynoteFile › Export To › PowerPoint, then use that .pptx. gleaner can’t read .key files
Google SlidesFile › 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 &.

CommandResult
gleaner ~/Downloads/"My Doc.zip" --dry-runLists 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 1500Embedded images shown 1500 px wide or more go into large/, the rest into images/
gleaner "My Doc.zip" --no-linksEmbedded images only. Needs no internet
gleaner "My Doc.zip" --no-embeddedLinked images only
gleaner "My Doc.zip" -o ~/Desktop/refsOutput 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:

ColumnMeaning
orderPosition in the doc or deck
kindembedded or link, or media for a video or audio file in a deck
wherebody, 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, rowNearest 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_textA little of the surrounding text, for finding it in the doc
sourceimages/imageN.png (ppt/media/imageN.png in a deck), or the link
methodHow it was fetched: wikimedia, google drive, dropbox, pexels, unsplash, direct, or page
statusWhat happened (below)
saved_asThe file, relative to the output folder
noteWhy it failed, or what to check
StatusMeaning
savedGot the real file
previewGot the page’s preview image, which may be smaller than the original. The file name ends in PREVIEW
rate-limitedThe site asked gleaner to slow down. Run again later
pageA web page with no image gleaner could take. It’s in open-by-hand.html
failedA login wall, a blocked script, a dead link, or a Drive file that isn’t shared. Also in open-by-hand.html
missingThe doc points to an image that isn’t in the export’s images/ folder
skippedA 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.

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:

LinkHow
Wikimedia Commons, or a Wikipedia …#/media/File:… linkAsks the Commons API for the original file. One request covers up to 50 titles
Google Drive fileThe direct-download address, which also gets past Drive’s virus-scan page on large files
DropboxSwitches dl=0 to dl=1
Pexels or Unsplash photo pageBuilds the full-size image address from the photo’s ID
A URL ending in an image extensionDownloads it as is
Any other pageSaves 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

SymptomFix
command not found: gleanerRun pyenv rehash, or use python3 -m gleaner. If neither works, re-run pip3 install -e ~/Developer/gleaner
can't open file … grab_tracker_media.pyThat’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 rowsWait 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 smallOpen 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 rowsThe zip was only partly extracted. Pass the .zip itself
Headings or row labels look wrong in the dry rungleaner 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 readIn 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 PowerPointThe deck is probably a .ppsx or .potx saved in an unusual way. Send it to Rafa
An .emf or .wmf file won’t openThese are old PowerPoint vector drawings. Open them in Preview, or drag them into Keynote
Nothing under linked/ at allYou’re offline, or you passed --no-links