Skip to content

Comments

@remotion/web-renderer: Support object-fit property#6206

Merged
JonnyBurger merged 5 commits intomainfrom
video-object-fit
Jan 3, 2026
Merged

@remotion/web-renderer: Support object-fit property#6206
JonnyBurger merged 5 commits intomainfrom
video-object-fit

Conversation

@JonnyBurger
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings January 3, 2026 12:22
@vercel
Copy link
Contributor

vercel bot commented Jan 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
bugs Ready Ready Preview, Comment Jan 3, 2026 0:49am
remotion Ready Ready Preview, Comment Jan 3, 2026 0:49am

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for the CSS object-fit property to the @remotion/web-renderer package, enabling proper rendering of images and canvas elements with different object-fit values (fill, contain, cover, none, scale-down).

Key Changes:

  • Implemented comprehensive object-fit calculation logic for all five CSS object-fit values
  • Refactored DOM element drawing to handle SVG and replaced elements separately
  • Added test coverage with visual regression testing for all object-fit modes

Reviewed changes

Copilot reviewed 7 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/web-renderer/src/drawing/calculate-object-fit.ts New file implementing object-fit calculation logic for all five CSS values (fill, contain, cover, none, scale-down)
packages/web-renderer/src/drawing/draw-dom-element.ts Refactored to separate SVG and replaced element rendering, integrating object-fit support for images and canvas elements
packages/web-renderer/src/test/object-fit.test.tsx Added test case for object-fit rendering verification
packages/web-renderer/src/test/fixtures/object-fit.tsx Created test fixture showcasing all five object-fit values in a grid layout
packages/web-renderer/src/test/Root.tsx Registered new object-fit composition for testing
packages/docs/docs/client-side-rendering/limitations.mdx Updated documentation to mark object-fit as supported and removed it from unsupported list
packages/web-renderer/package.json Added public directory configuration to studio and remotion scripts

const calculateContain = ({
containerSize,
intrinsicSize,
}: ObjectFitParams): ObjectFitResult => {
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

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

The calculateContain and calculateCover functions divide by containerSize.height and intrinsicSize.height without checking for zero values. If either of these values is zero, this will result in division by zero, leading to Infinity or NaN values in the calculations. Consider adding validation to ensure both container and intrinsic dimensions are positive before performing these calculations, similar to the validation in fitSvgIntoItsContainer function.

Suggested change
}: ObjectFitParams): ObjectFitResult => {
}: ObjectFitParams): ObjectFitResult => {
if (containerSize.height <= 0 || intrinsicSize.height <= 0) {
// Fall back to fill behavior if heights are invalid to avoid division by zero
return calculateFill({containerSize, intrinsicSize});
}

Copilot uses AI. Check for mistakes.
JonnyBurger and others added 2 commits January 3, 2026 13:36
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@JonnyBurger JonnyBurger merged commit 9753e0d into main Jan 3, 2026
12 of 15 checks passed
@JonnyBurger JonnyBurger deleted the video-object-fit branch January 3, 2026 12:36
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.

Web Renderer: Aspect ratio of <Video> is not right

1 participant