This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Build
zig build
# Build optimized
zig build -Doptimize=ReleaseSafe
# Run directly without installing
./zig-out/bin/imtools help
# Run with arguments
zig build run -- flatten --dry-runSingle-file Zig CLI tool (src/main.zig) with these major components:
- ImageType enum: File extension detection for PNG, JPEG, GIF, BMP, WebP, TIFF
- Image header parsing: Native binary parsing to read dimensions from image headers (no external libs)
- Commands: Each command is a standalone function (flattenImages, findDuplicates, deletePortraitImages, etc.)
- External tool integration: Uses
curlfor downloads,ffmpegfor conversions,ollamafor AI sorting
Key functions:
getImageDimensions()- Parses image headers to extract width/heightdownloadWallpapers()- Scrapes wallhaven.cc and downloads imagessortImages()- AI-powered categorization via Ollama vision modelsconvertToPng()- Batch conversion using ffmpeg
- ffmpeg: Required for
convert-to-pnganddownloadcommands - curl: Required for
downloadandsortcommands - ollama: Required for
sortcommand (AI image categorization)
When checking subprocess results in Zig, use proper tagged union access:
const success = switch (result.term) {
.Exited => |code| code == 0,
else => false,
};Do NOT use result.term.Exited directly - it will fail at runtime.