Skip to content

Crop & Resize: Add Borders to a fixed canvas, in a chosen colour (#86) - #104

Open
StuartCameronCode wants to merge 1 commit into
mainfrom
issue-86-borders
Open

StuartCameronCode wants to merge 1 commit into
mainfrom
issue-86-borders

Conversation

@StuartCameronCode

Copy link
Copy Markdown
Owner

Closes #86.

What users get

A new Borders section in Crop & Resize:

  • Add Borders pads the picture to a fixed canvas without rescaling it, independent of Resize — crop a dirty edge, border back out to the authoring size.
  • Canvas Preset in simple mode (PAL DVD 720×576, NTSC DVD 720×480, 720p, 1080p); exact width/height in advanced mode.
  • Border Colour: black / grey / white / custom #RRGGBB, also used by the existing Pad to Fill.
  • A picture larger than the canvas fails the job with a readable message instead of silently producing the wrong frame size.
  • Stamped sinceAppVersion: 1.2.0.

How

  • One {{#BORDERS}} step at the very end of both templates, after grain and after CHROMA_CONVERT, so nothing noises or resamples the bars. Pad to Fill's block now only records its box and uses the same step.
  • _border_color() converts the chosen RGB into the clip's own format via resize with the source's matrix/range (ColorMetadata::zimg_matrix / is_full_range).
  • Bug fix: AddBorders with no color= fills luma 0 — below video black on limited range. Pad to Fill's bars were therefore "blacker than black"; they are now 16 (8-bit) / 64 (10-bit).
  • Offsets stay on the chroma grid, and on the field grid when the picture is still interlaced (deinterlacing off + detected field order).

Tests

  • Rust: model unit tests; test_156–test_160 (canvas, bars-last ordering, matrix/range, field alignment, Pad to Fill sharing the step).
  • Flutter: converter round trip; script-gen test via the panel's dynamic values (push gate); new heavy integration_borders_test.dart — bar levels at 8-bit 4:2:0 and 10-bit 4:2:2, custom white = 940 at 10-bit, interior bit-identical positioning, oversize error, preview.
  • Mutation check: removing color= makes the heavy tests fail (luma 0 vs 16/64/940).
  • Locally (macOS arm64): cargo test green apart from the whisper test (add-on not installed); flutter test --exclude-tags heavy green; heavy aspect/upscale/borders suites green.

Found along the way, not fixed here

  • FFmpeg 9.0.1 converts pixels (not just tags) when -colorspace bt709 etc. is stamped on the untagged Y4M pipe — every tagged encode is colour-shifted.
  • Clean-aperture MOVs: ffmpeg applies the clap crop (720→702) and the decoder's -s 720x576 rescales it back.

Both are being handled on separate branches.

🤖 Generated with Claude Code

https://claude.ai/code/session_014GLXdGLfPwgYjW1AkonGqN

Adds a Borders section to Crop & Resize: pad the picture out to a fixed
canvas (PAL/NTSC DVD, 720p, 1080p presets, or an exact size in advanced
mode) without rescaling it, independent of Resize, with a black/grey/
white/custom fill colour.

All padding, including the existing Pad to Fill, now happens in one
BORDERS step at the very end of both templates, after grain and the
output format conversion, so nothing touches the bars. The fill is
converted into the clip's own format via resize with the source's
matrix and range, which also fixes Pad to Fill's bars: AddBorders'
default fill is luma 0, below video black on limited-range sources.
Offsets stay on the chroma grid, and on the field grid when the
picture is still interlaced; a picture larger than the canvas raises
rather than producing the wrong frame size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014GLXdGLfPwgYjW1AkonGqN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding Borders

1 participant