Sharpy
High-performance image sharpening library and CLI tool for Rust.
Want to play with it first? There's an optional Windows GUI demo with live sliders for every parameter — the fastest way to see what sharpy can do.
Quick Start
Library Usage
use Image;
// Load and sharpen an image
let image = load?;
let sharpened = image.unsharp_mask?;
sharpened.save?;
CLI Usage
# Install the CLI tool
# Sharpen an image
# Use a preset
Features
- Performance-focused - Parallel processing with Rayon
- Multiple algorithms - Unsharp mask, high-pass, edge enhancement, clarity
- Flexible API - Builder pattern for complex workflows
- Minimal dependencies - Core functionality with carefully selected dependencies
- CLI included - Full-featured command-line tool
- Optional GUI demo - Windows desktop app with live slider preview (see
sharpy-gui/)
Installation
As a Library
Add to your Cargo.toml:
[]
= "0.2"
As a CLI Tool
Or build from source:
Library Usage
Basic Sharpening
use ;
// Unsharp mask - the classic sharpening method
let image = load?;
let sharpened = image.unsharp_mask?;
// High-pass sharpening
let sharpened = image.high_pass_sharpen?;
// Edge enhancement
let sharpened = image.enhance_edges?;
// Clarity (local contrast enhancement)
let sharpened = image.clarity?;
Using the Builder Pattern
use ;
let result = load?
.sharpen
.unsharp_mask
.edge_enhance
.clarity
.apply?;
result.save?;
Using Presets
use ;
// Built-in presets for common use cases
let image = load?;
// Subtle sharpening
let result = subtle.apply?;
// Portrait enhancement (avoids over-sharpening skin)
let result = portrait.apply?;
// Landscape enhancement (enhanced detail)
let result = landscape.apply?;
Advanced Examples
Custom Sharpening Pipeline
use ;
Inspecting and Replaying Operations
Pipelines built with SharpeningBuilder can be inspected (e.g. for tests
that verify a preset still emits the expected stages) and individual
Operation values can be re-applied to any image:
use ;
let image = load?;
let builder = landscape;
// Inspect what stages the builder will run, in execution order.
for op in builder.operations
// Apply a single Operation directly.
let unsharp = UnsharpMask ;
let sharpened = unsharp.apply?;
Processing Multiple Images
use Image;
use *;
use Path;
Working with Image Data
use Image;
use ;
// From various image types (both return Result — see below)
let rgb_image = new;
let image = from_rgb?;
let dynamic_image = new_rgb8;
let image = from_dynamic?;
// Get dimensions and histogram
let = image.dimensions;
let histogram = image.histogram; // [u32; 256] luminance histogram
// Convert back to standard image types
let rgb: RgbImage = image.clone.into_rgb;
let dynamic: DynamicImage = image.into_dynamic;
CLI Tool (sharpy)
Basic Commands
# Unsharp mask with default settings
# Specify parameters
# High-pass sharpening
# Edge enhancement
# Clarity enhancement
# Use a preset
Available Presets
subtle- Light sharpening for general usemoderate- Balanced sharpening with claritystrong- Heavy sharpening for soft imagesedge-aware- Emphasizes edges while preserving smooth areasportrait- Optimized for portraits (avoids over-sharpening skin)landscape- Enhanced detail extraction for landscapes
Batch Processing
# Process all JPG files in current directory
# Process with custom suffix
# Apply multiple operations
Advanced CLI Usage
Dry Run Mode
# Preview what would happen without processing
Verbose Output
# See detailed processing information
Overwrite Protection
# Force overwrite existing files
Chaining Operations in Batch Mode
# Format: "operation:param1:param2:..."
Operation formats:
unsharp:radius:amount:thresholdhighpass:strengthedges:strength:method(method: sobel or prewitt)clarity:strength:radius
CLI Examples by Use Case
Portrait Photography
# Gentle sharpening for portraits
# Custom portrait enhancement
Landscape Photography
# Enhanced detail for landscapes
# Custom landscape workflow
Web Images
# Batch process for web upload
Scanned Documents
# Enhance text clarity
Optional GUI Demo
sharpy-gui is an optional Windows desktop app that lets you try every
sharpening parameter interactively. Drop an image onto the window, drag the
sliders, and watch the preview update in real time. Save when you're happy.
It's the easiest way to see what each algorithm does without writing any code.
What you get:
- Drag-drop or Open… to load any JPEG, PNG, BMP, TIFF, or WebP
- Live preview as you move sliders — runs on a downscaled copy for speed
- Six built-in presets in the toolbar dropdown (subtle, moderate, strong, edge-aware, portrait, landscape)
- Per-stage enable checkboxes and reset buttons
- Save As… runs the full-resolution pipeline on a worker thread, so the UI never freezes — even at the heaviest clarity settings
Run it from a checkout
# Debug build (faster to compile, slower to run)
# Release build (recommended for actual use)
The GUI is a separate workspace member, so this won't touch the library
or CLI build. Plain cargo build and cargo test at the root stay
lib-only.
Build a standalone .exe to share
# Binary: target/release/sharpy-gui.exe
The MSVC Rust toolchain links the C runtime statically, so the binary
is portable — copy the .exe to any Windows machine and double-click
to run. No installer, no Visual C++ Redistributable, no registry entries.
First-launch walkthrough
- Drag an image onto the window (or click Open…).
- Pick a preset from the toolbar dropdown to see a quick result.
- Tweak individual sliders in the right panel — radius, amount, threshold, etc. The preview updates as you drag.
- Save As… to write the result to disk at full resolution. The status bar shows progress and elapsed time.
For known limitations, the architecture overview, and details on the
preset-order quirk for edge-aware, see
sharpy-gui/README.md.
Performance
Sharpy uses parallel processing for optimal performance:
- Separable convolution for Gaussian blur
- Parallel pixel processing with Rayon
- Efficient memory usage with copy-on-write
- Optimized memory operations
Benchmark results on typical hardware (1024x1024 image):
- Unsharp mask: ~45ms
- High-pass sharpen: ~25ms
- Edge enhancement: ~35ms
- Clarity: ~65ms
*Performance may vary based on hardware and image characteristics.
Algorithm Details
Unsharp Mask
Creates a blurred version of the image and subtracts it from the original to enhance edges.
Parameters:
radius: Blur radius (0.5-10.0)amount: Strength multiplier (0.0-5.0)threshold: Minimum difference to sharpen (0-255)
High-Pass Sharpen
Uses a 3x3 convolution kernel to enhance high-frequency details.
Parameters:
strength: Blend with original (0.0-3.0)
Edge Enhancement
Detects edges using Sobel or Prewitt operators and enhances them.
Parameters:
strength: Enhancement amount (0.0-3.0)method: Edge detection algorithm (Sobel/Prewitt)
Clarity
Enhances local contrast by comparing each pixel to its surrounding area.
Parameters:
strength: Enhancement amount (0.0-3.0)radius: Local area size (1.0-20.0)
Building from Source
This is a Cargo workspace. The root crate (sharpy, library + sharpy
CLI) is the default member, so most commands at the root only touch the
library — the optional sharpy-gui member is built explicitly with -p.
# Clone the repository
# Build library + CLI (does NOT pull in GUI deps)
# Run tests (root crate only)
# Run benchmarks
# Install CLI globally
# Build the optional GUI demo (Windows-only target)
License
Licensed under the MIT License (LICENSE).
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.