MacOS Image Viewer
A native macOS application for browsing, viewing, and organizing your image collection
Overview
MacOS Image Viewer is a native SwiftUI application designed for macOS that provides a powerful and intuitive way to browse, view, and organize image collections. Built entirely with Swift and SwiftUI, it offers a modern, native macOS experience with features like folder browsing, tag-based organization and fullscreen viewing.
Key Features
📁 Folder Browsing
Browse image folders with a hierarchical tree view. Navigate through nested directories and quickly access your images.
🏷️ Tag System
Organize images with custom tags. Tags are stored in hidden .tag files next to each image, keeping metadata close to your files.
🔍 Tag-Based Search
Filter images by tags with an intuitive search interface. Autocomplete suggestions help you find and apply tags quickly.
🖼️ Image Viewing
View images with smooth zoom controls (0.5x to 5x magnification). Supports scrolling for large images that exceed the viewport.
🖥️ Fullscreen Mode
Immerse yourself in your images with fullscreen viewing mode. Toggle with keyboard shortcut (F key).
⌨️ Keyboard Shortcuts
Efficient navigation with keyboard shortcuts: F for fullscreen, T for tags, O for open folder, Escape to quit.
💡 Smart Suggestions
Tag autocomplete provides suggestions based on existing tags, making organization faster and more consistent.
Technology Stack
Architecture & Design
The application follows a modern SwiftUI architecture with clear separation of concerns:
Model Layer
The ImageItem struct represents individual images with their file URLs and associated tags.
Tags are stored as a Set of strings, normalized to lowercase for consistent searching. Each image item
is identifiable by its file URL.
ViewModel Layer
The ImageLibraryViewModel manages the application state, including:
- Image discovery and loading from selected folders
- Tag management (add, remove, persist, load)
- Search and filtering functionality
- Folder tree construction for navigation
- Tag persistence to hidden .tag files
- Global tag list management
View Layer
The application uses SwiftUI views organized into:
- ContentView: Main container with split view layout
- ImagePreview: Image display with zoom and scroll support
- TagEditor: Component for adding and managing tags
- AboutView: Application information window
- Custom Split Views: Horizontal and vertical split view implementations using NSSplitView
Tag Storage System
One of the unique features of this application is its file-system-based tag storage. Tags are stored in hidden text files (prefixed with a dot) next to each image. The tag file format is:
# image tags for <filename> created by ImageViewer v. 1.0
tag1,tag2,tag3
This approach has several advantages:
- Tags remain with the images, even if moved to different folders
- No central database required - tags are portable
- Tags can be edited with any text editor if needed
- Works well with version control systems (if tag files are included)
The application also maintains a global tag list in Application Support for quick autocomplete and suggestions across all images.
User Interface
The interface is organized into three main areas:
Left Panel - Image List
A hierarchical tree view showing folders and images. Folders can be expanded and collapsed. Images are displayed with their filenames. Selection in this panel updates the detail view.
Right Panel - Detail View
Split into two sections:
- Image Preview Area: Displays the selected image with zoom controls (0.5x to 5x) and scroll support
- Tag Controls: Shows the filename, current tags, and tag editor for adding new tags
Bottom Panel - Search Results
When tags are applied in the search, matching images are displayed here with thumbnails and their associated tags. Clicking a result selects that image in the main view.
Keyboard Shortcuts
The application supports several keyboard shortcuts for efficient navigation:
- O (Cmd+O): Open folder picker to select a new image folder
- T: Open quick tag dialog for the currently selected image
- F: Toggle fullscreen mode on/off
- Escape: Exit fullscreen mode (or quit application if not in fullscreen)
- Arrow Keys: Navigate between images in the list or search results
Supported Image Formats
The application supports the following image formats:
- JPEG (.jpg, .jpeg)
- PNG (.png)
- GIF (.gif)
Performance Features
- Lazy Loading: Images are loaded asynchronously when needed
- Thumbnail Generation: Thumbnails are generated for list views to improve performance
- Efficient Search: Tag-based filtering uses optimized set operations
- Smooth Scrolling: Custom split view implementations ensure smooth UI interactions
Project Structure
The project follows a clean architecture with organized directories:
ImageView/- Main application codeModels/- Data models (ImageItem.swift)ViewModels/- Business logic (ImageLibraryViewModel.swift)Views/- SwiftUI views (ContentView.swift, TagEditor.swift, AboutView.swift)ImageViewerApp.swift- Application entry pointAppDelegate.swift- Application delegate for window management
ImageView.xcodeproj/- Xcode project fileImageViewTests/- Unit testsImageViewUITests/- UI tests
Technical Highlights
Custom Split View Implementation
The application uses custom NSSplitView implementations (CustomVSplitView and
CustomHSplitView) to provide precise control over split positions, user adjustments,
and programmatic resizing. These components handle state management carefully to avoid SwiftUI
state modification warnings.
Animated GIF Support
GIF animation is handled through NSImageView with animation enabled. The
AnimatedGIFView component wraps NSImageView in a SwiftUI-compatible view,
allowing GIFs to play smoothly while maintaining zoom functionality.
Tag Persistence
Tags are persisted asynchronously to avoid blocking the UI. The system checks for write permissions and provides helpful error messages if tags cannot be saved. Tag files are created with a specific header format for validation.
Development & Building
The application is built using Xcode and requires:
- macOS 11.0 (Big Sur) or later
- Xcode 13.0 or later
- Swift 5.5 or later
To build and run:
1. Open ImageView.xcodeproj in Xcode
2. Select a target (macOS)
3. Build and run (Cmd+R)
4. Use "Open Folder…" to select a folder with images
Version Information
Current version: 1.0.0
Author: Thomas Byrdal
Built with Swift & SwiftUI • Native macOS Experience • Fast & Efficient