✅ Introduction

Image overlays provide inline image display functionality in org-mode files, similar to Emacs org-mode's image display feature. When enabled, image links are rendered as thumbnails directly in the editor, allowing you to preview images without opening them separately.

This feature enhances the visual experience of working with org documents that contain images, such as:

  • Scientific notebooks with plots and diagrams

  • Documentation with screenshots and illustrations

  • Journal entries with photos

  • Results from source block executions (especially Jupyter)

✅ How Image Overlays Work

Due to VS Code's limitations compared to Emacs overlays, the extension uses Hover Previews - Full-size image preview when hovering over image links

Thumbnails are automatically generated and cached for performance, using ImageMagick or native macOS tools when available.

✅ Supported Image Formats

The image overlay system supports the following image formats:

FormatExtension(s)Notes
PNG.pngFully supported
JPEG.jpg, .jpegFully supported
GIF.gifFully supported (static frames)
SVG.svgScalable vector graphics
WebP.webpModern web format
BMP.bmpBitmap images
TIFF.tiff, .tifTagged image format
ICO.icoIcon files

✅ Image Sizing and Attributes

✅ ATTRORG Keyword

Control how images are displayed using the #+ATTRORG: keyword above the image link:

#+ATTR_ORG: :width 400
[[_static/logo.svg]]

✅ Supported Attributes

AttributePurposeExample
:widthImage width (export):width 400
:heightImage height (export):height 300
:scaleScale factor (export):scale 0.5
:alignAlignment (export):align center
:altAlt text (export):alt "Description"

✅ Export-Specific Attributes

For LaTeX and HTML export, use backend-specific attributes:

See Export Documentation for more details on export attributes.

✅ Adding Captions

Add captions that appear in exports:

✅ Enabling and Disabling Image Display

✅ Global Toggle

Toggle image overlays for all org files:

✅ Per-File Toggle

Toggle image overlays for the current file only:

  • Command: Scimax: Toggle Image Overlays for Current File

  • Command ID: scimax.imageOverlays.toggleCurrentFile

This is useful when you want overlays disabled for one specific large document but enabled globally.

✅ Via Configuration

Permanently enable or disable in your settings.json:

{
  "scimax.imageOverlays.enabled": true
}

Set to false to disable by default.

✅ Configuration Settings

✅ scimax.imageOverlays.enabled

Enable or disable inline image thumbnails globally.

{
  "scimax.imageOverlays.enabled": true
}

✅ scimax.imageOverlays.maxWidth

Maximum width in pixels for thumbnail icons. Thumbnails are scaled down to fit within these dimensions while maintaining aspect ratio.

{
  "scimax.imageOverlays.maxWidth": 128
}

✅ scimax.imageOverlays.maxHeight

Maximum height in pixels for thumbnail icons.

{
  "scimax.imageOverlays.maxHeight": 128
}

✅ scimax.imageOverlays.renderMode

Controls where image thumbnails are displayed:

  • gutter - Show thumbnail in the editor gutter (line margin) - recommended

  • after - Show emoji and dimensions inline after the link text

  • both - Show both gutter thumbnail and inline decoration

{
  "scimax.imageOverlays.renderMode": "gutter"
}
  • Use gutter for a clean, unobtrusive experience

  • Use after if you prefer inline indicators

  • Use both for maximum visibility

✅ scimax.imageOverlays.excludePatterns

Regex patterns for image paths to exclude from overlay display. Useful for hiding certain directories or file patterns.

{
  "scimax.imageOverlays.excludePatterns": [
    "\\.tmp/",
    "/archive/",
    "draft-.*\\.png"
  ]
}

Examples:

  • "\\.tmp/" - Exclude images in .tmp directories

  • "^http" - Exclude remote URLs (already excluded by default)

  • "screenshot-.*" - Exclude files starting with "screenshot-"

✅ scimax.imageOverlays.maxOverlaysPerDocument

Maximum number of image overlays to display per document. This prevents performance issues in documents with hundreds of images.

{
  "scimax.imageOverlays.maxOverlaysPerDocument": 500
}

If your document exceeds this limit, you'll see a warning message.

✅ scimax.imageOverlays.showDimensions

When using after or both render modes, show image dimensions (e.g., "800x600") in the inline decoration.

{
  "scimax.imageOverlays.showDimensions": true
}

✅ scimax.imageOverlays.cacheEnabled

Enable thumbnail caching for faster loading. Thumbnails are stored in the extension's global storage directory.

{
  "scimax.imageOverlays.cacheEnabled": true
}

Set to false to disable caching (may impact performance).

✅ Images from Source Block Results

✅ Jupyter Kernel Output

Jupyter kernels automatically save image output to the .ob-jupyter/ directory:

import matplotlib.pyplot as plt
import numpy as np

plt.plot([1, 2, 3, 4], [1, 4, 9, 16])
plt.show()

These images are automatically displayed as overlays when image overlays are enabled.

See Jupyter Documentation for more details on Jupyter integration.

✅ Available Commands

✅ Scimax: Toggle Image Overlays

Toggle image overlays globally for all org files. When disabled, no thumbnails are shown but links remain functional.

✅ Scimax: Toggle Image Overlays for Current File

Toggle image overlays for the currently active org file only. Useful for temporarily hiding overlays in specific documents.

✅ Scimax: Refresh Image Overlays

Manually refresh all image overlays in visible editors. This can be useful if:

  • You've modified image files externally

  • Overlays aren't updating correctly

  • You've changed configuration settings

✅ Scimax: Clear Image Overlay Cache

Clear the thumbnail cache. This will:

  • Delete all cached thumbnails

  • Free up disk space

  • Force thumbnails to be regenerated on next display

Useful if thumbnails are corrupted or you want to reclaim space.

✅ Scimax: Show Image Overlay Cache Statistics

Display information about the thumbnail cache:

  • Number of cached thumbnails

  • Total cache size in KB

Useful for monitoring cache usage.

✅ Troubleshooting Image Display

✅ Images Not Showing

If image overlays aren't displaying:

  1. Check if overlays are enabled:

  2. Verify the image file exists:

  3. Check the file extension:

  4. Try refreshing:

  5. Check exclude patterns:

✅ Overlays Disappear When Editing

This is normal behavior when scimax.imageOverlays.onlyWhenCursorNotInLink is true (default). The overlay hides when your cursor is inside the link to prevent obscuring the text you're editing.

To always show overlays:

{
  "scimax.imageOverlays.onlyWhenCursorNotInLink": false
}

✅ Performance Issues

If you experience slow performance:

  1. Reduce the overlay limit:

  2. Reduce thumbnail size:

  3. Use gutter mode only:

  4. Disable overlays for specific files:

✅ Thumbnails Are Blurry or Corrupted

  1. Clear the cache:

  2. Check if ImageMagick is installed:

  3. Verify the original image isn't corrupted:

✅ Relative Paths Not Resolving

If relative paths aren't working:

  1. Use ./ prefix for clarity:

  2. Check your working directory:

  3. Use absolute paths as a workaround:

✅ Hover Preview Not Working

If hover previews aren't showing:

  1. Check hover delay:

  2. Verify hover provider is active:

  3. Try a different image format:

✅ Example Configuration

✅ Minimal Configuration

For basic image overlay functionality:

{
  "scimax.imageOverlays.enabled": true,
  "scimax.imageOverlays.renderMode": "gutter"
}

✅ Power User Configuration

For maximum visual feedback:

{
  "scimax.imageOverlays.enabled": true,
  "scimax.imageOverlays.maxWidth": 128,
  "scimax.imageOverlays.maxHeight": 128,
  "scimax.imageOverlays.renderMode": "both",
  "scimax.imageOverlays.onlyWhenCursorNotInLink": true,
  "scimax.imageOverlays.showDimensions": true,
  "scimax.imageOverlays.maxOverlaysPerDocument": 500,
  "scimax.imageOverlays.cacheEnabled": true
}

✅ Performance-Focused Configuration

For large documents with many images:

{
  "scimax.imageOverlays.enabled": true,
  "scimax.imageOverlays.maxWidth": 64,
  "scimax.imageOverlays.maxHeight": 64,
  "scimax.imageOverlays.renderMode": "gutter",
  "scimax.imageOverlays.onlyWhenCursorNotInLink": true,
  "scimax.imageOverlays.showDimensions": false,
  "scimax.imageOverlays.maxOverlaysPerDocument": 100,
  "scimax.imageOverlays.cacheEnabled": true,
  "scimax.imageOverlays.excludePatterns": ["archive/", "\\.tmp/"]
}

✅ Complete Example

Here's a complete example showing various image link formats:

,* My Research Notes

,** Experimental Results

The experiment produced the following results:

,#+CAPTION: Sine wave plot
,#+NAME: fig:sine
,#+ATTR_ORG: :width 400
[[file:./plots/sine-wave.png]]

As shown in Figure [[fig:sine]], the sine wave exhibits periodic behavior.

,** Data Visualization

,#+BEGIN_SRC jupyter-python :session analysis
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 2*np.pi, 100)
y = np.sin(x)

plt.figure(figsize=(10, 6))
plt.plot(x, y)
plt.title('Sine Wave')
plt.xlabel('x')
plt.ylabel('sin(x)')
plt.grid(True)
plt.show()
,#+END_SRC

,#+RESULTS:
[[file:.ob-jupyter/output-1705171200000-0.png]]

,** Screenshots

Here are some screenshots from the application:

[[./screenshots/main-window.png][Main Window]]
[[./screenshots/settings-dialog.png][Settings Dialog]]
[[./screenshots/export-preview.png][Export Preview]]

,** External Resources

Note: Remote images don't show overlays but are clickable:

[[https://example.com/logo.png][Company Logo]]

✅ Inserting Screenshots

The extension provides a cross-platform screenshot command that captures a screen region and inserts a link to the saved image.

✅ Taking a Screenshot

Press F10 in an org or markdown file to take a screenshot:

  1. Press F10 - the screen capture tool activates

  2. Select the area you want to capture (or press Escape to cancel)

  3. The screenshot is saved to a screenshots/ directory next to your file

  4. An image link is automatically inserted at the cursor position

PlatformTool Used
macOSscreencapture (built-in)
WindowsSnippingTool via PowerShell
LinuxAuto-detects: gnome-screenshot, scrot, flameshot, or maim

✅ macOS Permission Setup

The first time you use the screenshot command on macOS, you may need to grant screen recording permission to VS Code:

  1. Press F10 to trigger the screenshot

  2. macOS will show a permission dialog or the capture will fail silently

  3. Go to System Settings > Privacy & Security > Screen Recording

  4. Enable the checkbox for Visual Studio Code

  5. Restart VS Code for the permission to take effect

  6. Try F10 again

✅ Screenshot Directory

Screenshots are saved to a screenshots/ subdirectory relative to the current file. The directory is created automatically if it doesn't exist.

Filenames follow the pattern: screenshot-YYYY-MM-DD-HH-MM-SS.png

✅ Linux Screenshot Tools

On Linux, the extension tries these tools in order and uses the first one found:

  1. gnome-screenshot -a (GNOME desktop)

  2. scrot -s (lightweight, widely available)

  3. flameshot gui (feature-rich, popular choice)

  4. maim -s (modern alternative to scrot)

  5. import (ImageMagick, works everywhere)

Install at least one of these tools for screenshot functionality.

✅ Command Reference

CommandKeybindingDescription
scimax.insertScreenshotF10Capture screen region and insert link

✅ See Also

✅ Technical Details

✅ Thumbnail Generation

Thumbnails are generated using:

  1. ImageMagick (convert command) - Preferred, works on all platforms

  2. macOS sips - Native macOS tool, used as fallback on Mac

  3. Direct copy - If no tools available, original images are used

Thumbnails are cached in the extension's global storage directory with filenames based on:

  • MD5 hash of the original image path

  • Configured thumbnail dimensions

  • Original file extension

✅ Cache Location

Thumbnails are stored in:

  • Linux: ~/.config/Code/User/globalStorage/scimax-vscodeimage-overlay-cache

  • macOS: ~/Library/Application Support/Code/User/globalStorage/scimax-vscodeimage-overlay-cache

  • Windows: %APPDATA%\Code\User\globalStorage\scimax-vscode\image-overlay-cache\

✅ Performance Considerations

  • Thumbnail generation is asynchronous and doesn't block the editor

  • The cache prevents regenerating thumbnails on each file open

  • The maxOverlaysPerDocument setting prevents memory issues with large documents

  • Overlays are debounced during typing to avoid excessive updates

  • Gutter mode is more performant than after/both modes

✅ VS Code Limitations

Unlike Emacs, VS Code cannot:

  • Display arbitrary-sized inline images in the editor

  • Replace link text with actual image content

  • Provide true "overlay" functionality at the text level

The implementation uses VS Code's decoration API with gutter icons as the closest approximation to Emacs overlays.

Navigation