Skip to content

SpecterArdy/minimalimageviewer

 
 

Repository files navigation

Minimal Image Viewer

Project Logo

The most 🪶 LIGHTWEIGHT image viewer available for Windows


Minimal Image Viewer is an open-source, C++-based image viewing application engineered for Windows, prioritizing performance and minimalism. With a compiled size of only ~185KB. Leveraging native Windows APIs and the Windows Imaging Component (WIC), it ensures accurate functionality.



💾 Download the latest version here.


Key Features

  • Comprehensive Image Format Support:

    • Supports a wide array of formats via WIC, including JPEG, PNG, BMP, GIF, TIFF, ICO, WebP, HEIF, AVIF, and RAW formats (e.g., .cr2, .cr3, .nef, .dng, .arw, .orf, .rw2) with appropriate codecs installed.
    • Dynamically validates files as images using WIC’s IWICBitmapDecoder, enabling support for any WIC-compatible format without hardcoding extensions.
    • Preserves original file formats during save operations, ensuring fidelity for formats like TIFF and GIF.
  • Intuitive Navigation:

    • Directory-based image navigation via Left/Right arrow keys or context menu ("Next Image," "Previous Image").
    • Automatically indexes all WIC-supported images in the current directory, sorted lexicographically.
  • Flexible Viewing:

    • Smooth zoom (0.1x–10x) via Ctrl++/-, mouse wheel, or context menu, implemented with SetWorldTransform for GPU-friendly scaling.
    • Fits images to window (Ctrl+0 or double-click), adjusting for rotation angles.
    • Rotates images in 90° increments.
  • Image Management:

    • Saves rotated images (Ctrl+S or context menu) in their original WIC-supported format, using temporary files to ensure atomic operations.
    • Deletes images to the Recycle Bin (Delete key or context menu) for recoverable deletions.
    • Opens images with a comprehensive filter for common image formats, falling back to WIC for validation.
    • Copy the current view to the clipboard (Ctrl+C) or paste an image/file path from the clipboard (Ctrl+V).
  • Minimalist Interface:

    • Borderless window for a distraction-free experience, with dynamic cursor feedback for resizing.
    • Displays "Right click to see hotkeys" when no image is loaded, using GDI text rendering.
  • Window Control:

    • Supports window dragging (non-full-screen) and edge-based resizing.
    • Toggles full-screen mode (F11 or context menu) with automatic image fitting, preserving window state.
    • Exits via Esc or context menu, ensuring clean resource deallocation.
  • Single-Instance Enforcement:

    • Uses FindWindowW to prevent multiple instances, forwarding command-line arguments to the existing instance via WM_COPYDATA for memory management.

Security and Privacy

Minimal Image Viewer is designed for OpSec-sensitive environments, prioritizing a minimal attack surface and zero telemetry.

  • Offline Operation:

    • No network activity or telemetry, ensuring complete data privacy.
  • Minimal Attack Surface:

    • The modular codebase is easy to audit. It relies exclusively on hardened, native Windows APIs and WIC, avoiding third-party library dependencies.
    • Strict memory management mitigates buffer overflows and leaks, validated with static analysis tools.
  • Safe File Handling:

    • Opens files with shared access (FILE_SHARE_READ | FILE_SHARE_WRITE) to prevent lock-based exploits.
    • Saves via temporary files to ensure atomic writes, minimizing data loss risks.
    • Deletes to Recycle Bin with user confirmation, preventing accidental permanent data loss.
  • No Registry Modifications:

    • Operates without persistent system changes, leaving no forensic footprint beyond the executable.

Why Modular?

Minimal Image Viewer adheres to the Unix philosophy of “do one thing and do it well,” offering distinct advantages:

  • Efficiency: Minimal resource usage (<10 MB RAM, ~100 KB disk) enables integration into resource-constrained workflows, outperforming bloated alternatives like Windows Photos (~100 MB RAM).
  • Security: Focused functionality reduces attack vectors compared to feature-heavy tools with cloud integration or telemetry (e.g., Windows Photos, Adobe Bridge).
  • Flexibility: Complements specialized tools (e.g., ExifTool, RawTherapee) for workflows in photography, digital forensics, or development.
  • Maintainability: Small codebase simplifies updates, security patches, and community contributions.

Comparison with Alternatives

Feature Minimal Image Viewer Windows Photos IrfanView XnView
Executable Size ~0.18 MB ~50 MB ~3 MB ~5 MB
Dependencies None (Windows APIs) UWP Framework Optional Plugins Optional Plugins
Telemetry None Yes Optional Optional
Offline Operation Yes Partial Yes Yes
Image Format Support WIC-dependent (all formats) Codec-dependent Plugin-dependent Plugin-dependent
Open-Source Yes No No No
Footprint (RAM) <10 MB ~100 MB ~20 MB ~30 MB

Minimal Image Viewer excels in size, privacy, and format support, leveraging WIC’s extensibility for unparalleled compatibility.

System Requirements

  • OS: Windows 10 or later (64-bit recommended for optimal WIC codec support).
  • Dependencies: None (uses standard Windows libraries: user32, gdi32, windowscodecs, etc.).
  • Image Format Support: Supports all WIC-compatible formats; advanced formats (e.g., WebP, HEIF, AVIF) require installed codecs (e.g., Microsoft Store extensions).
  • Disk Space: 400 KB.
  • Memory: <10 MB runtime for typical images, scaling with image resolution.

Installation and Usage

  1. See the release page for single .exe, or build yourself (instructions below).

  2. Controls:

    • Open: Ctrl+O or right-click → "Open Image".
    • Navigate: Left/Right arrows or right-click → "Next/Previous Image."
    • Zoom: Ctrl++/-, mouse wheel, or right-click → "Zoom In/Out"; Ctrl+0 or double-click to fit.
    • Rotate: Up/Down arrows or right-click → "Rotate Clockwise/Counterclockwise."
    • Save: Ctrl+S or right-click → "Save Image" (preserves original format).
    • Delete: Delete or right-click → "Delete Image" (to Recycle Bin).
    • Full-Screen: F11 or right-click → "Full Screen."
    • Move/Resize: Drag window or edges (non-full-screen).
    • Exit: Esc or right-click → "Exit."
    • Copy: Ctrl+c.
    • Paste: Ctrl+v
  3. If you are having difficulties setting as your main image viewer, see setting as default viwer.

Technical Highlights

Minimal Image Viewer is architected for high performance, minimal resource usage, and robust security, leveraging native Windows technologies.

Core Implementation

  • Windows API:

    • Creates a borderless window, minimizing UI overhead.
    • Implements double buffering for flicker-free rendering at 60+ FPS.
    • Supports edge-based resizing with dynamic cursor updates, disabled in full-screen mode for seamless viewing.
  • Windows Imaging Component (WIC):

    • Decodes images with IWICBitmapDecoder and IWICBitmapFrameDecode, using nullptr GUID to support all WIC-compatible formats dynamically.
    • Converts to GUID_WICPixelFormat32bppPBGRA via IWICFormatConverter for GDI compatibility, ensuring consistent rendering across formats.
    • Applies rotations with IWICBitmapFlipRotator, leveraging hardware acceleration for 90° increments.
    • Saves images using IWICBitmapEncoder, dynamically selecting the original container format (decoder->GetContainerFormat) to preserve file type fidelity.
    • Validates directory files as images by attempting IWICBitmapDecoder creation, ensuring broad format support without hardcoded extensions.
  • Graphics and Transformations:

    • Renders images with StretchBlt in HALFTONE mode for high-quality scaling, optimized for various display DPIs.
    • Applies zoom and rotation via SetWorldTransform, centering images using matrix transformations for precise positioning.
    • Uses CreateDIBSection for direct pixel access, minimizing memory overhead (<10 MB for typical images).
  • File System Operations:

    • Indexes directory images with FindFirstFileW and FindNextFileW using a *.* wildcard, filtering via WIC’s IsImageFile function for format-agnostic support.
    • Opens files with FILE_SHARE_READ | FILE_SHARE_WRITE and STGM_SHARE_DENY_NONE to prevent access conflicts, even in multi-process environments.
    • Deletes to Recycle Bin with SHFileOperationW and FOF_ALLOWUNDO, ensuring recoverable file operations.
    • Saves images atomically using temporary files (MoveFileExW with MOVEFILE_REPLACE_EXISTING) to handle file locks robustly.

Performance Optimizations

  • Minimal Footprint:

    • Compiles to a ~185 KB executable with /O2 optimization, requiring <10 MB runtime memory for most images.
    • No external dependencies beyond standard Windows libraries (user32.lib, gdi32.lib, windowscodecs.lib, etc.).
  • Resource Management:

    • Strictly manages WIC (Release) and GDI (DeleteObject) resources to prevent memory leaks, verified with tools like Application Verifier.
    • Closes file handles (CloseHandle) immediately after use to ensure system resource availability.
    • Uses FindWindowW to prevent multiple instances, forwarding command-line arguments to the existing instance via WM_COPYDATA for memory management.

Build Process

  • Tools: Microsoft C++ compiler (cl.exe) and Resource Compiler (rc.exe)).
  • Resources: Links minimallogo.ico via resource.rc for custom branding.
  • Build Commands:
    • Visual Studio:
      rc.exe /fo resource.res resource.rc
      cl.exe /O2 /EHsc /Fe:MinimalImageViewer.exe main.cpp ui_handlers.cpp image_drawing.cpp image_io.cpp resource.res /link /SUBSYSTEM:WINDOWS user32.lib gdi32.lib comdlg32.lib shlwapi.lib windowscodecs.lib ole32.lib shell32.lib propsys.lib oleaut32.lib

Contributing

Contributions are welcome.

To contribute:

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature/YourFeature).
  3. Commit changes (git commit -m "Add YourFeature").
  4. Push to the branch (git push origin feature/YourFeature).
  5. Open a pull request, ensuring alignment with the project’s minimalist and security-focused philosophy.

Include unit tests (e.g., for new WIC format handling) and update documentation for new features.


Minimal Image Viewer: A fast, secure, and extensible image viewer for privacy-conscious professionals.

About

The most lightweight image viewer for Windows, supporting a wide range of image formats.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 91.0%
  • CMake 8.7%
  • C 0.3%