Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply best practices for creating programmatic videos with Remotion and React
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
rules/images.md
1## Sizing and positioning23Use the `style` prop to control size and position:45```tsx6<Img7src={staticFile("photo.png")}8style={{9width: 500,10height: 300,11position: "absolute",12top: 100,13left: 50,14objectFit: "cover",15}}16/>17```1819## Dynamic image paths2021Use template literals for dynamic file references:2223```tsx24import { Img, staticFile, useCurrentFrame } from "remotion";2526const frame = useCurrentFrame();2728// Image sequence29<Img src={staticFile(`frames/frame${frame}.png`)} />3031// Selecting based on props32<Img src={staticFile(`avatars/${props.userId}.png`)} />3334// Conditional images35<Img src={staticFile(`icons/${isActive ? "active" : "inactive"}.svg`)} />36```3738This pattern is useful for:3940- Image sequences (frame-by-frame animations)41- User-specific avatars or profile images42- Theme-based icons43- State-dependent graphics4445## Getting image dimensions4647Use `getImageDimensions()` to get the dimensions of an image:4849```tsx50import { getImageDimensions, staticFile } from "remotion";5152const { width, height } = await getImageDimensions(staticFile("photo.png"));53```5455This is useful for calculating aspect ratios or sizing compositions:5657```tsx58import {59getImageDimensions,60staticFile,61CalculateMetadataFunction,62} from "remotion";6364const calculateMetadata: CalculateMetadataFunction = async () => {65const { width, height } = await getImageDimensions(staticFile("photo.png"));66return {67width,68height,69};70};71```72