A Rust application that solves nonogram puzzles (picross/griddlers/hanjie/logimage) through logical deduction. Analyzes an image, automatically extracts constraints, and outputs the solution in ASCII/JSON/Array format or generates a marked image.
- Automatic constraint extraction from filled cells (no OCR needed!)
- Multi-format export: ASCII (console), JSON, Array2D
- Interactive mode for manual constraint entry
- Simplified command:
nonogram-solver image.pngjust works - Console output by default with solved grid
- 100% pure Rust: No non-Rust dependencies for main features
- ✨ Automatic extraction: Analyzes filled cells to derive constraints
- 🖼️ Multi-format support: JPEG, PNG, BMP, GIF, TIFF, WebP
- 📤 Multi-format export: ASCII (█/✕/·), JSON structured, Array2D (1/0/-1)
- 🎮 Interactive mode: Manual constraint entry in terminal
- 🧩 Pure logical deduction: Solving algorithms without guessing
- 🎨 Visual marking (optional): Generate image with deductions marked in red
- 🏆 Three solvers: Basic, Advanced, Ultimate (backtracking + parallelization)
- Rust 1.91 or higher
- C compiler (gcc/clang) for native dependencies
# Clone the project
git clone https://github.com/your-username/nonogram-solver.git
cd nonogram-solver
# Build in release mode
cargo build --release
# Binary will be in target/release/nonogram-solver# Automatic analysis + console ASCII output
./target/release/nonogram-solver image.png# Export as JSON
./target/release/nonogram-solver -i image.png --export solution.json
# Export as 2D array
./target/release/nonogram-solver -i image.png --export solution.txt
# Export as ASCII explicitly
./target/release/nonogram-solver -i image.png --export solution.txt --export-format ascii# Automatic extraction from filled cells (default)
./target/release/nonogram-solver -i image.png --extract-filled
# Interactive mode (manual entry)
./target/release/nonogram-solver -i image.png --interactive
# With JSON file (classic method)
./target/release/nonogram-solver -i image.png -c constraints.json| Option | Description |
|---|---|
-i, --input <FILE> |
Input nonogram image |
-o, --output <FILE> |
Output image (optional) |
-e, --export <FILE> |
Export grid to file |
--export-format <FMT> |
Format: ascii, json, array |
--extract-filled |
Auto-extract from filled cells |
--interactive |
Interactive constraint input |
--extract-only |
Extract and display without solving |
--advanced |
Advanced solver |
--ultimate |
Ultimate solver (backtracking + parallel) |
-v, --verbose |
Verbose mode |
# Auto extraction + ultimate solver + JSON export
./target/release/nonogram-solver \
-i puzzle.png \
--extract-filled \
--ultimate \
--export solution.json \
--verbose
# Interactive mode with output image
./target/release/nonogram-solver \
-i puzzle.png \
--interactive \
-o solution.png
# Extract only (no solving)
./target/release/nonogram-solver \
-i puzzle.png \
--extract-only \
--export grid.txt✕ ✕ █ █ █
✕ ✕ █ █ █
█ █ █ █ █
{
"width": 5,
"height": 3,
"cells": [
["crossed", "crossed", "filled", "filled", "filled"],
...
]
}[
[-1, -1, 1, 1, 1],
[-1, -1, 1, 1, 1],
[1, 1, 1, 1, 1]
]
grid/: Grid representation (CellState,Grid,Constraints)solver/: Solving algorithms (NonogramSolver,AdvancedSolver,UltimateSolver)image_parser/: Image analysis and grid detectionimage_generator/: Image generation with markingsgrid_output/: Multi-format export (ASCII, JSON, Array2D)interactive/: Interactive constraint inputocr(optional): Tesseract-based constraint extraction
- Basic: Line-by-line deduction with cache
- Advanced: Cross-analysis + advanced heuristics
- Ultimate: All techniques + backtracking + parallelization
# Build
cargo build
# Run tests
cargo test
# Format code
cargo fmt
# Run linter
cargo clippy
# Release build
cargo build --release- 5x5 grid: < 0.1 seconds
- 10x10 grid: < 0.5 seconds
- 20x20 grid: < 3 seconds
- 30x30 grid: < 10 seconds
JPEG, PNG, BMP, GIF, TIFF, WebP
MIT
Built with ❤️ in Rust