94f3fab41c
- Updated 10 NuGet packages: SharpCompress 0.49.1, Magick.NET-Q8-x64 14.14, System.Drawing.Common 10.0, itext 9.6, Imazen.WebP 11.0, McMaster 5.1, iTextSharp 5.5.13.5, Imageflow 0.15.1, Magick.NET.SystemDrawing 8.0.23 - Fixed missing OnExecuteAsync -- CLI was throwing InvalidOperationException on launch - Added -w|--new-webp flag (Imageflow encoder path; benchmarked consistently slower) - Added -P|--par-archive: parallel image compression within each archive Batched 3-phase design: sequential read -> Parallel.For (ProcessorCount/2 threads) -> sequential write; ordering guaranteed by indexed slots; ~4-5x measured speedup - Added par_archive to ProcessorFlags - Added CLAUDE.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3.4 KiB
3.4 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Solution Structure
Three projects in ComicCompress.sln, all targeting .NET 8.0:
- ComicCompress (this directory) — Console application entry point.
Program.cshandles CLI parsing viaMcMaster.Extensions.CommandLineUtilsand orchestrates processing. - iMGcompress-core (
../iMGcompress-core) — Class library containing all compression logic. Both the CLI and GUI depend on this. - iMGcompress (
../iMGcompress) — Windows Forms GUI (net8.0-windows) wrapping the core library.
Build & Run
# Development build
dotnet build
# Run CLI (from project root)
dotnet run -- --help
dotnet run -- -i <input> -o <output> -q 75 -p
# Publish self-contained Windows executable
dotnet publish -r win-x64 -c Release
launchSettings.json defines named profiles (e.g. PROD, DEV_HOME, Compress Image to webp) for common invocations.
CLI Flags
| Flag | Description |
|---|---|
-i |
Input file or folder (required) |
-o |
Output base path (default: converted_comics) |
-r |
Recurse into subfolders |
-s |
Skip if output already exists |
-q |
WebP quality 0–100 (default: 75) |
-p |
Parallel processing (all CPUs) |
-c |
Parallel with N CPUs |
-d |
PDF-only mode |
-j |
Image-only mode |
-n |
Zebra PRN mode (generates PNG + WebP Base64 URI) |
-a |
Copy unprocessed files to output |
Architecture
Data flow: Input (.cbr/.cbz archives or loose images) → extract → convert each image to WebP → repack as .cbz.
Core library (iMGcompress-core)
Compressor.cs— Central engine. Reads RAR/ZIP archives viaSharpCompress, converts images to WebP viaImazen.WebP, and writes output.cbz. Handles solid and non-solid archives separately. The first image in an archive (cover) is preserved without conversion.FileProcessor.cs— Orchestrates parallel or sequential processing over a file list. Inner classProcessorFlagscarries all options. Writes the final compression report.FileParser.cs— Recursively enumerates input files.ImageExtractor.cs— ImplementsIRenderListener(iText) to extract images from PDF pages and produce a.cbz.PixelMap.cs— Parses Portable Bitmap formats (PBM/PGM/PPM, variants P1–P6) intoSystem.Drawing.Bitmapbefore WebP encoding.Logger.cs— Thread-safe colored console/file logger.LogLevel: Error, Warning, Info, Verbose.file_stat.cs— Simple DTO tracking per-file uncompressed/compressed sizes for statistics.
Console app (ComicCompress)
Program.cs parses flags, builds a ProcessorFlags, calls FileParser to enumerate targets, then hands off to FileProcessor. Video (MP4→WebM) conversion uses Xabe.FFmpeg. Zebra PRN rendering uses BinaryKits.Zpl.Viewer.
Key Dependencies
| Package | Purpose |
|---|---|
SharpCompress |
Read/write RAR and ZIP archives |
Imazen.WebP + libwebp.dll |
WebP encoding (requires libwebp.dll in output dir) |
Magick.NET-Q8-x64 |
Advanced image format support (TIFF, etc.) |
iTextSharp / itext |
PDF parsing |
Xabe.FFmpeg |
Video conversion |
BinaryKits.Zpl.Viewer |
Zebra PRN label rendering |
McMaster.Extensions.CommandLineUtils |
CLI argument parsing |
libwebp.dll must be present alongside the executable at runtime — it is checked into the repo root.