Improve knowledge discovery by reusing icons. Create an image library with Excalidraw Script Engine
Based on Zsolt's Visual Personal Knowledge Management's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.
Use a strict icon filename convention starting with “icon,” followed by keywords and a dashed source segment to make icons both searchable and reusable.
Briefing
A practical way to reuse icons inside Excalidraw drawings hinges less on finding good artwork and more on treating icon files like structured data. By enforcing a naming convention (including keywords and the image source) and then auto-building an icon grid from those files, knowledge workers can turn a personal vault into a searchable, copy-pasteable image library—while also strengthening cross-document connections.
The workflow starts with file naming. Icons are stored as files whose names begin with a consistent prefix (“icon” for icons), followed by one or more keywords (e.g., “icon joy happiness”), and then a dashed source segment (e.g., the source “nick milo” embedded in the filename). That structure makes icons discoverable and reusable later, because the system can reliably match files by keyword and preserve provenance. Without this discipline, reusing visuals becomes tedious: icons may exist, but they’re hard to locate and hard to trust.
From there, the method automates library creation. An Excalidraw Script Engine script scans an Obsidian vault via the Obsidian API, filters for non-markdown files whose base filename contains “icon” (case-insensitive), and sorts them alphabetically. The script then uses Excalidraw’s Automate API to reset the canvas and place each icon image into a grid layout—six columns by default, with rows added as needed. For each image, it calculates x/y coordinates based on the current column and row, adds the image to the canvas, and resizes it to fit within fixed width/height constraints while preserving aspect ratio. Once all images are placed, the script zooms to fit and switches the drawing into view mode so the icons can be copied into other documents without UI clutter.
A key usability step is making the library load automatically. The script is embedded into the Excalidraw file’s front matter using an “on load script” tag (so the icon grid regenerates whenever the drawing opens). Because Excalidraw expects the script content in a compact form, a helper “conversion” script reads the clipboard and strips newline characters (and collapses extra spaces) before embedding the final one-line script. This avoids manual cleanup and makes the setup repeatable.
The approach also includes debugging guidance: when running scripts from the Script Engine, errors can be harder to pinpoint, but the developer console allows defining the Automate API object (EA) and executing the script directly in the active view. The result is a repeatable pipeline: enforce icon filenames, auto-generate an icon library grid from vault files, and load it automatically into an Excalidraw workspace for fast reuse—turning visual assets into a navigable knowledge layer rather than scattered images in folders.
Overall, the core insight is that icon reuse becomes scalable only when visuals are named consistently and then rendered into a structured, auto-updating library that supports copy-paste workflows inside Excalidraw—making visual connections easier to maintain across a growing knowledge base.
Cornell Notes
The method turns an Obsidian vault of icon files into an auto-generated Excalidraw image library. It relies on a strict naming convention: filenames start with “icon,” include one or more keywords, and embed the image source after a dash. An Excalidraw Script Engine script scans the vault, filters non-markdown files whose names include “icon,” and lays them out in a grid on the canvas using Excalidraw Automate APIs. Each image is resized to fit fixed cell dimensions while preserving aspect ratio, then the canvas zooms to fit and switches to view mode for easy copy-paste. Finally, an “on load script” front-matter tag makes the library regenerate automatically when the Excalidraw file opens, with a helper that strips newlines for reliable embedding.
Why does the naming convention matter more than the icon artwork itself?
How does the script decide which files become part of the icon library?
What turns a list of icon files into a usable Excalidraw grid?
Why is resizing necessary after adding images to the canvas?
How does the library become automatic when opening an Excalidraw file?
What’s the best way to debug when the Script Engine run fails?
Review Questions
- What exact filename checks does the script perform to decide which vault files become icons, and why is case-insensitivity important?
- Describe how the script computes x/y placement for each icon and how it handles moving from one row to the next.
- What steps are required to make the icon library regenerate automatically on Excalidraw open, and why might newline removal be necessary?
Key Points
- 1
Use a strict icon filename convention starting with “icon,” followed by keywords and a dashed source segment to make icons both searchable and reusable.
- 2
An Excalidraw Script Engine script can scan an Obsidian vault, filter non-markdown files containing “icon” in the base name, and sort them for predictable output.
- 3
Excalidraw Automate APIs can render a grid of icons by computing x/y coordinates from fixed cell dimensions and padding.
- 4
After adding each image, resizing logic preserves aspect ratio so icons fit cleanly into the grid without distortion or overflow.
- 5
Switching to view mode after rendering keeps the workspace copy-friendly while hiding editing tools.
- 6
Embedding the script via an Excalidraw on-load front-matter tag makes the icon library regenerate automatically when the drawing opens.
- 7
A clipboard-to-on-load-script conversion helper removes newlines and extra spaces to prevent formatting issues when embedding the script.