A Chrome extension that adds a full-screen pan-and-zoom viewer for images in Google Docs.
Google Docs renders document images onto canvas tiles, making them difficult to inspect at full resolution. This extension intercepts the canvas rendering pipeline to capture image URLs, then provides a lightbox viewer when you click on an image.
- Clone this repository:
git clone https://github.com/timaeus-research/gdocs-image-expand.git - Open Chrome and go to
chrome://extensions - Enable Developer mode (toggle in the top-right corner)
- Click Load unpacked and select the cloned
gdocs-image-expandfolder - Open any Google Doc containing images
- Click on an image in a Google Doc — Google Docs will show its selection handles
- An expand button (arrow icon) appears near the top-right of the selected image
- Click the expand button to open the full-screen viewer
In the viewer:
- Scroll to zoom in/out (zooms relative to the center of the image)
- Drag to pan around
- Double-click to reset the view
- Escape, click the X button, or click the dark backdrop to close
Keyboard shortcut: Ctrl+Shift+E opens the viewer for the most recently captured image (useful if the expand button doesn't appear).
Google Docs uses a canvas-based rendering engine — document images are painted onto <canvas> tiles via drawImage() rather than being accessible as <img> elements.
The extension has two components:
-
inject.jsruns in the page's main JavaScript context (atdocument_start). It monkey-patchesCanvasRenderingContext2D.prototype.drawImageto intercept images as Google Docs paints them onto canvas tiles, capturing their blob URLs and positions. -
content.jsruns in Chrome's isolated content script world. It receives captured image data viapostMessage, detects when you select an image (by watching for Google Docs'docs-squarehandleselectionbox-borderelement), and provides the expand button and lightbox viewer.
To share with others, either point them to this repository or zip the folder and send it. Recipients follow the same installation steps above.
- Hard reload required: After installing or updating the extension, do a hard reload of the Google Doc (
Cmd+Shift+R/Ctrl+Shift+R) so that the canvas hooks load before Google Docs renders. - Chrome will show a "Developer mode extensions" banner periodically — this is normal for unpacked extensions and can be dismissed.
- The extension only runs on
docs.google.com/document/*pages.