Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.
fix(video): a cut filmed at another size than the first frame reads the standing height on its own
Soohong Kim8f8efc1abce8
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8bd610f..38b0711 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -11,8 +11,8 @@ All notable public changes to `sprite-gen` are recorded here. Versions track the- **`tests/video/test_edge_speck_lead_in.py`**: a walk or run forced wide is 1969 × 1108 with nothing above, a jump still 2800 × 1575.- **Fix: `video-loop` leaves a walk's lead-in out of the search.** A video model may reframe a small subject in a clip's first frames — the body grows or shrinks by a third or more in under half a second, then walks at its new size. Searched with those frames, the motion analysis read the reframing as the clip's motion and lost the walk's repeat, and the gait fallback, scaling back by a line through the clip, read the step as steady growth and shrank the walk. A walk or run's sizes are now read one cycle on (`gait_fallback.cycle_drift`, the size hold's model) and a clip whose first frame's height and size (the square root of the frame's coverage) are both off it by 10 % or more, the same way (`LEAD_IN_MIN`), opens on a lead-in (`gait_fallback.lead_in`) that runs while the height stays that far off — a reframing scales the whole body, a pose such as an item held up from the second frame on changes the height alone; `--cycle auto` and `periodic` — the size hold, the motion analysis, the cycle search and the gait fallback — read the clip after it as a clip of its own, window included. Every frame number the report gives is the clip's own: `cycle.start`, each candidate's `start` and `context_pair_range`, a refusal's windows too, so `--cycle fixed --start` taken from them cuts the frames they name. Every walk and run report gains `lead_in` (`frames`, `height_change`, `first_off`, `first_off_size`, `min`, `method`, `search_from`); a clip too short to read its size one cycle on has none (`why`). A cut the caller names (`fixed`, `pinned`) is the caller's frames. `cycle.coverage` counts the frames the search read. The gait fallback now scales back by the size read one cycle on, as the hold does, so a first pose settling into the walk no longer hides a body that grows from it (`gait_fallback.scale_drift` gains `method: one-cycle-on` in the report); a clip that reaches the fallback with 3 % or more of change is scaled by that model now, and its pixels and the drift its refusal quotes can differ in the last places. A walk or run with no lead-in that the first search cuts is cut as before, its strip, GIF, WebP, cycle frames and `strip.json` byte for byte. [docs/video-pipeline.md](docs/video-pipeline.md#4-loop--period-first-seam-second-then-the-gait-floor), [docs/loop-review.md](docs/loop-review.md#the-gait-fallback-a-slow-walk-or-a-walk-toward-the-camera).-- **Fix: after a lead-in, `--body-height` reads the standing height on the cut's first frame.** The clip's first frame is the still's pose as filmed, but a walk that opens on a lead-in films it at another scale: read there, the standing height scaled the walk up into the cell cap. Such a cut now reads it on its own first frame, and `strip.json` says so (`body_ref: cut-first-frame`, `body_ref_frame`, the clip frame); `video-cycle-align` rebuilds such a strip at the same height. A clip with no lead-in reads its first frame as before, and its `strip.json` is as before. [docs/video-pipeline.md](docs/video-pipeline.md#4-loop--period-first-seam-second-then-the-gait-floor).-- **`tests/video/test_edge_speck_lead_in.py`**: a walker filmed at 0.63 of its size and reframed over 9 frames: a lead-in of 5 frames, found no cycle before, now cuts its 24-frame walk after it, every frame number its own; one filmed at 1.3 of its size has a lead-in too, and one that holds an item up from its second frame on has none; too slow a walk after the same lead-in is refused with windows that all start after it; a fixed cut there reads its standing height on its own first frame, and `video-cycle-align` keeps it. A walker that settles from its first pose and grows 5 % reads 2.8 % on a line and was refused; read one cycle on it is scaled back and cut.+- **Fix: `--body-height` reads the standing height on the cut's first frame where the cut is filmed at another size than the clip's first.** The clip's first frame is the still's pose as filmed, but a video model may reframe the subject after it, by a lead-in or by less, and then the walk is filmed at another size than that pose: read there, the standing height scaled a walk after a lead-in up into the cell cap, and delivered a walk reframed by 7 % over its first frames 7 % too large. A walk or run cut for a `--body-height` now has its size read against the first frame's (`gait_fallback.size_change`) on three lengths at once — the height, the mass (the square root of the summed coverage) and the breadth (the widest row of the upper half of the body), each the middle of the cut's frames over the first frame's. A pose moves them apart (a walk is shorter than its standing pose and broader; an item held up is taller and no heavier) and a reframing moves all three the same way, so the change is the least of the three when all go one way and none when they part. At 1 % or more (`SIZE_HOLD_MIN`) the standing height is read on the cut's own first frame, and `strip.json` says so (`body_ref: cut-first-frame`, `body_ref_frame`, the clip frame); `video-cycle-align` rebuilds such a strip at the same height. The report gains `cut_size` (`change`, `height`, `mass`, `breadth`, `min`, `method`) on every walk and run cut for a `--body-height`. A cut the size of its first frame reads the first frame as before, and its strip, GIF, WebP, cycle frames and `strip.json` are as before. [docs/video-pipeline.md](docs/video-pipeline.md#4-loop--period-first-seam-second-then-the-gait-floor).+- **`tests/video/test_edge_speck_lead_in.py`**: a walker filmed at 0.63 of its size and reframed over 9 frames: a lead-in of 5 frames, found no cycle before, now cuts its 24-frame walk after it, every frame number its own; one filmed at 1.3 of its size has a lead-in too, and one that holds an item up from its second frame on has none; too slow a walk after the same lead-in is refused with windows that all start after it; a fixed cut there reads its standing height on its own first frame, and `video-cycle-align` keeps it; a walker reframed from 0.93 of its size, or from 1.07, opens no lead-in, and a fixed cut after it read the first frame's height (7 % too large or small) and now reads its own first frame's; a first pose that settles into the walk, an item held up from the second frame on and an arm swung out are each read as a pose, on the first frame. A walker that settles from its first pose and grows 5 % reads 2.8 % on a line and was refused; read one cycle on it is scaled back and cut.- **Fix: `video-frames` erases a speck far from the body before the edge check.** A fleck the model drew drifting across the background survives the matte as a few pale pixels; where it crossed an edge band in one frame, the edge check read it as the subject framed too tight and refused the clip, and `video-loop --anchor motion-auto`, which never cleans a frame, kept it in the loop and widened every cell to reach it. Now every keyed frame has its specks erased before anything reads it (`frames.drop_specks`): a piece of the frame — its opaque pixels, corners joining them — under 1 % of the body (`SPECK_MIN_FRACTION`, at least 8 px) and more than a tenth of the body's height from it (`SPECK_APART`). Small pieces near the body are the subject's own and stay: the outline's loose pixels, a shadow drawn under a shoe, a part of a shoe the matte cut loose. Each report row gains `specks`, how many its frame lost, and the report `specks` (`dropped`, `frames` and the rule's numbers); a frame with no speck is not written again, so its bytes are as before. `video-loop`'s own pass on a cut that is not motion-reviewed (`--anchor none|feet|body`) erases every island of solid pixels under the same 1 % as before, pixel for pixel, through the same function (a run-based labelling, about twenty times faster than the pixel-by-pixel search it replaces). [docs/video-pipeline.md](docs/video-pipeline.md#3-frames--extract-key-check-the-edges).- **`tests/video/test_edge_speck_lead_in.py`** keys a body on magenta with five pale pixels in its right edge band in one frame: before this the frames were refused as framed too tight, now the fleck is erased (`specks: 1`) and no frame touches the edge; a shadow under the feet, a loose pixel by the outline and a far block too large to be a speck are kept; `video-loop`'s own reading still erases the loose pieces. A walker on magenta with a fleck drifting far from it, keyed and cut `--anchor motion-auto`, is cut 49 px wide, the walker alone (147 px before).diff --git a/docs/video-pipeline.md b/docs/video-pipeline.mdindex c599ba7..6bf2357 100644--- a/docs/video-pipeline.md+++ b/docs/video-pipeline.md@@ -971,11 +971,22 @@ Outputs:character size (`--strip-height` stays the cap). With a target, the standing height ismeasured on the **clip's first frame** instead — the base still's pose, which every clipstarts from — because the tallest grounded frame of an attack is its windup with the weapon- overhead, and scaling that to N shrank the character against its walk. A walk or run that opens- on a lead-in (section 4) films that pose at another scale than the walk, so there the standing- height is read on the cut's own first frame (`body_ref: cut-first-frame`, and `body_ref_frame`,- the clip frame it was read on); read on the first frame, filmed small, it scaled the walk up into- the cell cap. The sidecar says which (`body_ref`: `first-frame`, `cut-first-frame` or+ overhead, and scaling that to N shrank the character against its walk. A video model may+ reframe the subject after the first frame — a lead-in (section 4), or less — and then the walk+ is filmed at another size than that pose: read on the first frame, filmed small, the standing+ height scaled the walk up, a lead-in's into the cell cap. So a walk or run cut for a+ `--body-height` has its size read against the first frame's (`gait_fallback.size_change`) on+ three lengths at once: the height, the mass (the square root of the summed coverage) and the+ breadth (the widest row of the upper half of the body), each the middle of the cut's frames+ over the first frame's. A pose moves them apart — a walk is shorter than its standing pose and+ broader, an item held up is taller and no heavier — and a reframing moves all three the same+ way, so the cut's change of size is the least of the three when all go one way, and none when+ they part. It is the cautious reading: a reframing smaller than what the pose itself moves one+ of the lengths by, the other way, stays a pose (a small shrink under a walk's broader body,+ for one). At 1 % or more (`SIZE_HOLD_MIN`) the standing height is read on the cut's own first+ frame (`body_ref: cut-first-frame`, and `body_ref_frame`, the clip frame it was read on). The+ report records the reading (`cut_size`: `change`, `height`, `mass`, `breadth`, `min`). The+ sidecar says which frame (`body_ref`: `first-frame`, `cut-first-frame` or`tallest-grounded`) and records `body_src_h` and `scale`. `delay_ms = cycle_seconds / frames`, so a24 fps clip yields 41.67 ms cells; render at 24 fps to keep one cell per frame(a 30 fps render of 24 fps cells is a 5:4 pulldown and judders).diff --git a/sprite_gen/video/gait_fallback.py b/sprite_gen/video/gait_fallback.pyindex 9dda1eb..6f4e0b7 100644--- a/sprite_gen/video/gait_fallback.py+++ b/sprite_gen/video/gait_fallback.py@@ -36,6 +36,12 @@ pose moves one — an item held up from the second frame on lengthens the body anothing to its mass, legs spread in a side step add mass and no height. The lead-in runs on whilethe height stays that far off, that way; the height is the steadier of the two through a walk. Awalk's own frames stray from the model by a few percent; a reframing starts tens of percent off it.++A reframing too small to open a lead-in still films the walk at another size than the clip's first+frame, which is where `--body-height` reads the standing height. `size_change` reads how much larger+(or smaller) a cut is filmed than that frame, on three lengths of the body at once (`body_size`: its+height, its mass, the breadth of its upper half), and counts only what all three agree on: a pose+moves them apart, a reframing moves them together."""from __future__ import annotations@@ -59,6 +65,10 @@ SIZE_HOLD_MIN = 0.01# whose height and size are both this far off, the same way, opens a lead-in, and the frames whose height# stays this far off, that way, are in it (`lead_in`).LEAD_IN_MIN = 0.1+# The part of the body, from its crown down, whose widest row is its breadth (`body_size`): the head, the+# shoulders and the arms down to the hands — where a walk swings its arms, so a walking pose is broader+# than the standing one it is shorter than, and the two lengths part on a pose.+BREADTH_PART = 0.5# The longest cycle the second search accepts, as a share of the clip and in seconds.LONG_CYCLE_FRACTION = 0.6LONG_CYCLE_SECONDS = 2.0@@ -210,6 +220,44 @@ def lead_in(frames: list[Image.Image], *, min_lag: int, max_lag: int) -> dict:"first_off_size": round(float(off_size[0]), 4), **base}+def body_size(frame: Image.Image) -> tuple[float, float, float] | None:+ """Three lengths of the subject as drawn, each of which a frame filmed 5 % larger reads 5 % longer:+ its height (its rows, as `loop.standing_height` reads them), its mass (the square root of its summed+ coverage) and its breadth (the widest row, by summed coverage, of its upper `BREADTH_PART`). A frame+ with no subject is None."""+ alpha = np.asarray(frame.getchannel("A"), np.float64)+ rows = np.nonzero((alpha >= 8).any(axis=1))[0]+ if not len(rows):+ return None+ top, height = int(rows[0]), int(rows[-1]) + 1 - int(rows[0])+ coverage = alpha.sum(axis=1) / 255+ upper = coverage[top: top + max(1, round(BREADTH_PART * height))]+ return float(height), float(np.sqrt(coverage.sum())), float(upper.max())+++def size_change(first: tuple[float, float, float] | None, cut: list[tuple[float, float, float] | None]) -> dict:+ """How much larger the cut is filmed than the clip's first frame (`body_size` of each): +0.07 is 7 %+ larger, 0 the same size.++ The first frame is the standing pose and the cut is the walk, so every length differs between them by+ the pose alone: a walk is shorter than its standing pose (knees bend) and broader (arms swing, legs+ part), and its mass goes either way. A reframing scales the body whole, so it moves the height, the+ mass and the breadth by the same part, the same way. Each length of the cut is the middle of its+ frames' (one frame's legs are apart, the next one's together) over the first frame's, less 1+ (`height`, `mass`, `breadth`); `change` is the least of the three when all go one way, and 0 when+ they part — what cannot be the pose, so a reframing smaller than what the pose moves one length by,+ the other way, reads 0 as well. A first frame, or a cut, with no subject reads 0, and `why` says so."""+ base = {"min": SIZE_HOLD_MIN, "method": "least-of-height-mass-breadth"}+ sizes = [size for size in cut if size is not None]+ if first is None or not sizes:+ return {"change": 0.0, "height": None, "mass": None, "breadth": None, **base,+ "why": "no subject in the clip's first frame" if first is None else "no subject in the cut"}+ off = np.median(np.asarray(sizes, np.float64), axis=0) / np.asarray(first, np.float64) - 1+ change = float(np.sign(off[0]) * np.abs(off).min()) if (off > 0).all() or (off < 0).all() else 0.0+ return {"change": round(change, 4), "height": round(float(off[0]), 4), "mass": round(float(off[1]), 4),+ "breadth": round(float(off[2]), 4), **base}++def undo_padding(frames: list[Image.Image], measured: dict) -> tuple[int, int, int, int]:"""Left, top, right, bottom room every frame needs so `undo_scale` cuts nothing.diff --git a/sprite_gen/video/loop.py b/sprite_gen/video/loop.pyindex ba8ace0..aa2cb2e 100644--- a/sprite_gen/video/loop.py+++ b/sprite_gen/video/loop.py@@ -654,8 +654,8 @@ def standing_height(path: Path, frame: int = 0) -> int:Every clip starts from its still (image-to-video), so this is the same pose in everystate of one character — which is what one `--body-height` across states has to measure- to give that character one size. A clip that opens on a lead-in is read on the cut's first- frame instead (run_loop): its first frame is at another scale.+ to give that character one size. A walk or run whose cut is filmed at another size than the+ clip's first frame is read on the cut's first frame instead (run_loop)."""box = Image.open(path).convert("RGBA").getchannel("A").point(lambda v: 255 if v >= 8 else 0).getbbox()if box is None:@@ -688,8 +688,8 @@ def build_strip(frames: list[Image.Image], *, max_cells: int = STRIP_MAX_CELLS,floor = max(b[3] for b in boxes)grounded = [b[3] - b[1] for b in boxes if b[3] >= floor - 4] or [b[3] - b[1] for b in boxes]# `standing_src` is the caller's own measurement of the standing pose (run_loop: the clip's- # first frame, or the cut's first — clip frame `standing_frame` — where the clip opens on a- # lead-in). The tallest grounded frame counts whatever is raised overhead — an attack's+ # first frame, or the cut's first — clip frame `standing_frame` — where the cut is filmed at+ # another size than it). The tallest grounded frame counts whatever is raised overhead — an attack's# windup lifts the weapon above the head — and would shrink that state against the others.body_src = standing_src if standing_src is not None else max(grounded)# max_height is a ceiling on the CELL; an explicit body_height is a target for the BODY.@@ -1247,8 +1247,13 @@ def run_loop(cycle_dir = out_dir / "cycle"frames: list[Image.Image] = []scrubbed = specks = 0+ # A walk or run cut for a `--body-height` has its frames' sizes read as filmed, for the standing height below.+ sized = body_height is not None and prof.gait+ cut_sizes = []for k, f in enumerate(files[i : i + L]):im = Image.open(f).convert("RGBA")+ if sized:+ cut_sizes.append(gait_fallback.body_size(im))# Motion review is pixel preserving: cleanup belongs to the keyed input (`video-frames` erases# the specks far from the body). The other cuts erase every loose piece of solid pixels under# the speck size, wherever it is: the outline's islands and a drawn shadow as well.@@ -1335,9 +1340,16 @@ def run_loop((out_dir / FOLLOW_SOURCE).unlink(missing_ok=True)for k, im in enumerate(frames):im.save(cycle_dir / f"frame-{k:03d}.png")- # The standing height is the base still's pose as filmed, the clip's first frame — but a clip that opens- # on a lead-in films that pose at another scale than the walk: there it is read on the cut's own first frame.- standing_frame = i if lead is not None and lead["frames"] else 0+ # The standing height is the base still's pose as filmed, the clip's first frame — but a video model that+ # reframes the subject after it films that pose at another size than the walk. Where the cut is filmed+ # SIZE_HOLD_MIN or more larger or smaller than the first frame (gait_fallback.size_change: what its height,+ # mass and breadth all agree on, so not a pose), the standing height is read on the cut's own first frame.+ # A lead-in is such a reframing, and so is one too small to open a lead-in.+ standing_frame = 0+ if sized:+ report_base["cut_size"] = gait_fallback.size_change(gait_fallback.body_size(Image.open(files[0]).convert("RGBA")), cut_sizes)+ if abs(report_base["cut_size"]["change"]) >= gait_fallback.SIZE_HOLD_MIN:+ standing_frame = istrip, strip_meta = build_strip(frames, max_height=strip_height, cycle_seconds=cycle_seconds, body_height=body_height, anchor="feet" if anchor == "feet" else "none", kind=str(cycle.get("kind") or "periodic"),standing_src=standing_height(files[standing_frame], standing_frame) if body_height is not None else None,standing_frame=standing_frame)diff --git a/tests/video/test_edge_speck_lead_in.py b/tests/video/test_edge_speck_lead_in.pyindex ead93ab..38162a8 100644--- a/tests/video/test_edge_speck_lead_in.py+++ b/tests/video/test_edge_speck_lead_in.py@@ -6,8 +6,9 @@ small subject are not part of its walk, and a walk forced wide gets no room abovreads a key-tinted pixel in the edge band as the subject's rim when its piece holds the subject too.* `video-loop` reads a walk's lead-in (the first frames off the walk's size) and searches the clip after it;what it finds, and what it refuses, is said in the clip's own frame numbers. The gait fallback scales back- by the size read one cycle on, as the hold does. A cut after a lead-in reads the standing height on its- own first frame.+ by the size read one cycle on, as the hold does. A cut filmed at another size than the clip's first frame —+ after a lead-in, or after a reframing too small to open one — reads the standing height on its own first+ frame; a pose the first frame lacks is not another size.* `video-canvas --shape wide` gives a walk or run room in front and behind and none above."""from __future__ import annotations@@ -270,6 +271,7 @@ def test_a_cut_after_a_lead_in_reads_the_standing_height_on_its_own_first_frame(assert meta["scale"] == round(120 / meta["body_src_h"], 4)assert meta["body_ref"] == "cut-first-frame" and meta["body_ref_frame"] == 12assert out["lead_in"]["frames"] >= 4 and out["lead_in"]["search_from"] == 0 # a named cut is the caller's frames+ assert out["cut_size"]["change"] > 0.5 and out["cut_size"]["min"] == gait_fallback.SIZE_HOLD_MIN# `video-cycle-align` rebuilds the strip at the same standing height.for name in ("a", "b"):shutil.copytree(tmp_path / "out", tmp_path / name)@@ -283,7 +285,73 @@ def test_a_cut_of_a_clip_with_no_lead_in_reads_its_first_frame_as_before(tmp_patout, meta, keyed = _fixed(tmp_path, [walks.walker(k) for k in range(73)], 12)assert meta["body_ref"] == "first-frame" and "body_ref_frame" not in metaassert meta["body_src_h"] == _height(keyed / "000.png")+ assert out["lead_in"]["frames"] == 0 and out["cut_size"]["change"] == 0++[email protected]("start, first, change", [(0.93, 112, 0.063), (1.07, 129, -0.068)])+def test_a_cut_filmed_at_another_size_than_the_first_frame_reads_the_standing_height_on_its_own_first_frame(tmp_path, start, first, change):+ # Reframed by 7 % over its first 9 frames, the walker opens no lead-in (under LEAD_IN_MIN), and its walk is+ # filmed 7 % larger (or smaller) than its first frame: read there, the standing height delivered the walk+ # 7 % too large (or small).+ out, meta, keyed = _fixed(tmp_path, [zoomed(k, start=start) for k in range(73)], 12)assert out["lead_in"]["frames"] == 0+ assert abs(_height(keyed / "000.png") - first) <= 1 and meta["body_src_h"] == _height(keyed / "012.png") == 120+ assert (meta["body_ref"], meta["body_ref_frame"], meta["scale"]) == ("cut-first-frame", 12, 1.0)+ size = out["cut_size"]+ assert size["change"] == pytest.approx(change, abs=0.01)+ # ... the least of what the height, the mass and the breadth say, which all go the one way.+ assert abs(size["change"]) == min(abs(size[k]) for k in ("height", "mass", "breadth")) >= gait_fallback.SIZE_HOLD_MIN+ assert len({size[k] > 0 for k in ("height", "mass", "breadth")}) == 1+++def _item_held_up(k: int) -> Image.Image:+ image = walks.walker(k)+ if k:+ image.paste((120, 120, 120, 255), (140, 30, 142, 48))+ return image+++def _arm_swung_out(k: int) -> Image.Image:+ image = walks.walker(k)+ if k:+ image.paste((20, 90, 180, 255), (155, 90, 167, 96))+ return image++[email protected]("pose", [walks.settling, _item_held_up, _arm_swung_out])+def test_a_pose_the_first_frame_lacks_is_not_another_size(tmp_path, pose):+ # The first frame stands tall on straight legs and settles into the walk (5 % shorter, lighter, as broad);+ # or the walk holds an item up that the first frame does not (17 % taller, no heavier); or swings an arm+ # out (a third broader, as tall). Each moves one or two of the height, the mass and the breadth, and a+ # reframing moves all three the same way: the standing height stays the first frame's.+ out, meta, keyed = _fixed(tmp_path, [pose(k) for k in range(73)], 12)+ assert meta["body_ref"] == "first-frame" and "body_ref_frame" not in meta+ assert meta["body_src_h"] == _height(keyed / "000.png")+ size = out["cut_size"]+ assert size["change"] == 0 and out["lead_in"]["frames"] == 0+ moved = {k for k in ("height", "mass", "breadth") if abs(size[k]) >= gait_fallback.SIZE_HOLD_MIN}+ assert moved == {walks.settling: {"height", "mass"}, _item_held_up: {"height"}, _arm_swung_out: {"breadth"}}[pose]+++def test_the_size_of_a_cut_is_what_its_height_mass_and_breadth_all_agree_on():+ size, first = gait_fallback.size_change, (100.0, 50.0, 30.0)+ larger = size(first, [(107.0, 53.0, 32.0)])+ assert (larger["change"], larger["height"], larger["mass"], larger["breadth"]) == (0.06, 0.07, 0.06, 0.0667)+ assert size(first, [(93.0, 46.0, 29.0)])["change"] == -0.0333+ # Shorter and lighter but as broad, or shorter and broader: a pose.+ assert size(first, [(96.0, 49.0, 30.0)])["change"] == 0 and size(first, [(97.0, 53.0, 33.0)])["change"] == 0+ # Each length of the cut is the middle of its frames': one frame's stride is not the cut's size.+ assert size(first, [first, (110.0, 55.0, 33.0), first])["change"] == 0+ assert size(first, [(110.0, 55.0, 33.0), first, (110.0, 55.0, 33.0), None])["change"] == 0.1+ # Nothing to read it on: no change, and why.+ assert gait_fallback.body_size(Image.new("RGBA", (40, 40))) is None+ assert size(None, [first])["change"] == 0 and "first frame" in size(None, [first])["why"]+ assert size(first, [None])["change"] == 0 and "cut" in size(first, [None])["why"]+ # A frame's three lengths: its rows, the square root of its coverage, the widest row of its upper half.+ block = Image.new("RGBA", (60, 60))+ block.paste((200, 0, 0, 255), (10, 10, 30, 50))+ block.paste((200, 0, 0, 255), (5, 40, 45, 50)) # broader below the middle: not its breadth+ assert gait_fallback.body_size(block) == (40.0, math.sqrt(20 * 30 + 40 * 10), 20.0)# --- a walk forced wide ---------------------------------------------------------------------------------------