Skip to content

andrestubbe/FastThumb

Repository files navigation

FastThumb

Native Windows 11 Thumbnail Extraction for Java (Explorer-Parity, High-DPI, Zero-Copy)

FastThumb is an ultra-fast, native thumbnail extractor for Windows 10/11. It leverages IShellItem + IShellItemImageFactory — the exact same APIs used by Windows Explorer. It provides High-DPI thumbnails (up to 512px+), folder previews, video keyframes, and composite thumbnails, perfectly integrated into the FastJava ecosystem.

Features

  • Explorer-Parity — Identical thumbnails to Windows Explorer (colors, cropping, DPI, video frames, folder preview logic).
  • High-DPI Support — 32px → 512px → unbounded. No 48px limitation like Java ShellFolder.
  • Zero-Copy JNI Pipeline — Native DIB → DirectByteBuffer → FastImage.
  • Folder Preview Logic (Win11) — Micro-thumbnails, composite layouts, and content-sampling.
  • Video & Multimedia — Keyframes, album art, PDF/Office previews (via Explorer backend).
  • STA-Thread Engine — COM Thumbnail APIs run in a dedicated STA thread for maximum stability.
  • FastJava Integration — Seamlessly combines with FastIO, FastFileIndex, FastImage, and FastWindow.

Java API

public final class FastThumb {
    /**
     * Extracts a thumbnail for a single file or folder.
     * Returns a FastImage (ARGB, zero-copy).
     */
    public static FastImage get(Path path, int size);

    /**
     * Extracts a folder preview (composite thumbnail showing contents).
     */
    public static FastImage getFolder(Path folder, int size);

    /**
     * Check if FastThumb is supported on the current system.
     */
    public static boolean isSupported();
}

Returns

  • FastImage (ARGB, direct, zero-copy).
  • Guaranteed High-DPI and Explorer-consistent.

Error Handling

  • Item without thumbnail → null (falls back to icon if available).
  • Folder empty → null.
  • Not supported → isSupported() == false.

Usage Example

Path p = Paths.get("C:/Users/Andre/Pictures/IMG_00123.JPG");
FastImage img = FastThumb.get(p, 256);

if (img != null) {
    viewer.draw(img); // FastWindow / FastUI
}

Folder Preview:

FastImage preview = FastThumb.getFolder(Paths.get("C:/Users/Andre/Pictures"), 256);

Architecture

Java
 └── FastThumb.get(path, size)
       ↓ JNI (Zero-Copy)
Native (C++)
 ├── CoInitializeEx(STA) (Dedicated Thread)
 ├── SHCreateItemFromParsingName
 ├── IShellItemImageFactory::GetImage(size)
 ├── HBITMAP → DIB → DirectByteBuffer
 └── return to Java (FastImage)

Guarantees

  • Always STA-Thread: All COM operations are proxied to a dedicated Single-Threaded Apartment thread to prevent deadlocks and undefined behavior.
  • Always High-DPI: Leverages IShellItemImageFactory for high-resolution assets (256px, 512px, 1024px) without scaling artifacts.
  • Always Explorer-Parity: Matches the exact Windows look and feel, including video frame overlays and folder contents.
  • Zero-Copy: Pixels are written directly into a native buffer that FastImage manages. No intermediate int[] copies.

Performance

Operation FastThumb Java ShellFolder Speedup
128px Thumbnail 0.3 – 1.2 ms 20 – 40 ms ~30x
256px Thumbnail 0.5 – 2.0 ms Not supported
512px Thumbnail 3.0 – 5.0 ms Not supported
Folder Preview 1.0 – 4.0 ms Not supported

Note: Benchmarks performed on Windows 11, NVMe SSD.

Folder Preview Logic (Windows 11)

FastThumb replicates the exact Explorer heuristic:

  • Sampling: Samples the first N files for content previews.
  • Prioritization: Images > Videos > Documents.
  • Grid Layout: Automatic 2x2 or 3x3 composite grid for folders.
  • DPI Awareness: Renders micro-thumbnails at the appropriate scale.

Roadmap

  • IThumbnailCache Integration — Persistent cache hits for sub-millisecond retrieval.
  • Async Batch Extraction — Non-blocking extraction for large directories.
  • Video Keyframe Override — Custom decoders for specific video offsets.
  • DirectStorage Prefetch — FastIO integration for lightning-fast loading.
  • FastUI ThumbnailGrid — GPU-accelerated component for browsing thousands of items.

Requirements

  • Windows 10/11 (x64)
  • Java 17+
  • FastImage (Required for zero-copy returns)

Made with ⚡ by Andre Stubbe

About

High-performance native Windows 11 thumbnail extraction for Java. Leverages Shell COM APIs (IShellItemImageFactory) for lightning-fast, OS-native folder previews, video thumbnails, and high-DPI assets with zero-copy JNI integration. Part of the FastJava ecosystem.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors