Skip to content

Preserve aspect ratio when exported frames change size - #615

Merged
Breakthrough merged 2 commits into
Breakthrough:mainfrom
aswanth-07:fix/resize-exported-images-per-frame
Nov 22, 2026
Merged

Breakthrough merged 2 commits into
Breakthrough:mainfrom
aswanth-07:fix/resize-exported-images-per-frame

Conversation

@aswanth-07

Copy link
Copy Markdown
Contributor

With save_images(threading=False, width=80), a video that changes from 160 × 80 to 160 × 120 produces two 80 × 40 images. The second image should be 80 × 60. In the single-threaded path, the inferred height becomes the requested height for the rest of the export. Setting only height causes the same problem with the inferred width.

Use the resize helper already called by the threaded path so each frame infers its own missing dimension.

Validation

  • Added regression tests for width-only and height-only export in both threading modes. Both single-threaded cases fail on main and pass with this change.
  • Reproduced the bug with an H.264 clip that changes resolution midstream. After the fix, both modes export 80 × 40 and 80 × 60 PNGs with width=80.
  • Ran all 149 tests in tests/test_output.py. Ruff lint and formatting passed.

AI tools assisted with investigation and implementation.

@aswanth-07
aswanth-07 marked this pull request as ready for review November 21, 2026 11:37

@Breakthrough Breakthrough left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Note there's some pyright issues you need to address before this can be landed, can you take a look and address those? Also can we add a changelog entry for this?

Re: the pyright issue I think we can just assert that the decoded image is not None in the test you added before we read .shape.

@Breakthrough Breakthrough added this to the 0.7.4 milestone Nov 22, 2026
@aswanth-07

Copy link
Copy Markdown
Contributor Author

Updated in 168068d. The test now asserts that each exported image decodes before it reads .shape, which clears the pyright reportOptionalMemberAccess error at tests/test_output.py:215. The changelog has a Development entry for the fix.

Locally, pyright 1.1.414 now gives the same result as main: its only error is the unresolved optional moviepy import, because moviepy isn't installed here. Ruff lint and formatting pass, and all 149 tests in tests/test_output.py pass. The workflows for this head are waiting for approval.

@Breakthrough
Breakthrough force-pushed the fix/resize-exported-images-per-frame branch from 168068d to cdf6a44 Compare November 22, 2026 22:53
@Breakthrough
Breakthrough merged commit 11d167c into Breakthrough:main Nov 22, 2026
@Breakthrough

Copy link
Copy Markdown
Owner

Thanks for the PR!

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.

3 participants