feat(image): add ImageMagick-equivalent ops (shave/deskew/colors/colorspace/contrast-stretch/density) #16
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/magick-ops"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Native Rust equivalents of six common
magickflags, exposed undermonkey image:image shave --width N --height N-shave WxHimage deskew [--threshold DEG]-deskew[-15°, +15°]in 0.5° steps on a downsampled grayscale copy, then bilinear counter-rotation.--thresholddefault is1.0so sub-degree noise detections are ignored.image colors --count N-colors Ncolor_quantcrate.Nmust be in2..=256.image colorspace --space gray|srgb-colorspacegrayuses Rec. 709 luminance;srgbis identity.image contrast-stretch [--black F] [--white F]-contrast-stretch BLACK%xWHITE%[0, 1].image density --dpi DPI-density DPIFive of these are pixel transforms on the existing
ImageBufand dispatch throughrun_filter.colorsreturnsResult(range check) anddensityoperates on paths (noImageBufround-trip), so both have explicit dispatch arms.New dependency:
color_quant = "1"(MIT/Apache-2.0).Unit tests in
src/image/magick_ops.rscover dimensions, parameter validation, gray equalisation, and contrast expansion (10 new tests; full suite 39 passing). End-to-end smoke test against amagick-generated 100x60 line drawing confirmed each subcommand produces correct output dimensions and thatmonkey image density --dpi 300round-trips through ImageMagick's identifier as118.11 ppcm(= 300 DPI).cargo fmt --check,cargo clippy --all-targets -- -D warnings,cargo build --all-targets, andcargo testall pass on this branch.Test plan
Checkworkflow passes for this branch.monkey image shave,deskew,colors,colorspace,contrast-stretch, anddensityagainst a real document and visually compare to the equivalentmagickinvocation.monkey image density --dpi 300 in.png out.pngreports 300 DPI in viewers that read the pHYs chunk.monkey image density --dpi 300 in.jpg out.jpgreports 300 DPI in viewers that read the JFIF density bytes.