mirror of
https://github.com/storytold/photocraft.git
synced 2026-10-29 04:17:11 -06:00
Fixes #933. With no selection the whole document is measured, and `selection_mask` sized its mask with `r.width() * r.height()` in u32. A legal 65536×65536 document (2^32 pixels) overflowed the product, so `run` panicked and dispatch reported an internal error; in release the product wraps to 0, `gray_image` still renders the full region (~64 GiB of f32 RGBA) and `measure_features` then indexes the empty mask. `selection_rows` now computes the pixel count in u64 before anything is allocated and refuses more than `MAX_MEASURE_PIXELS` (400 MP) with an error that says to select a smaller region; the mask is sized from that checked count. The measurement label counter is also bumped only after the rows are computed, so a failed measurement no longer skips a number. Co-authored-by: wstock <1394687+wstock@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>