An image layer draws a still picture from a file next to your project.
{ "id": "logo", "type": "image", "src": "assets/logo.svg", "width": 240, "y": "40%" }| field | default | notes |
|---|---|---|
src | required | Path relative to the project file. |
width, height | native size | Set one to scale with the aspect ratio kept; set both to define a box. |
fit | cover | How the picture fills a box when both width and height are set. |
cornerRadius | 0 | Rounds the visible picture. "50%" on a square image makes a circle. |
Everything else is a common field: position, anchor, rotation, scale, opacity, shadow,
blur, brightness, saturation, blend modes, presets, masks.
#Formats
| format | notes |
|---|---|
| PNG, JPEG, WebP, BMP | decoded at native resolution; transparency is kept |
| GIF | the first frame only. To play an animated GIF, use a video layer with the same src |
| SVG | rendered as vectors at the size it is displayed, so it stays sharp at any size |
Check a file's pixel size before laying it out with vidmake probe:
$ vidmake probe assets/logo.svg
[
{
"path": "assets/logo.svg",
"kind": "image",
"duration": null,
"width": 200,
"height": 200,
"fps": null,
"hasVideo": true,
"hasAudio": false,
"videoCodec": null,
"audioCodec": null,
"sampleRate": null
}
]validate fails with the resolved path when a src does not exist, so a typo never reaches a render.
#Sizing
- Neither
widthnorheight: the image is shown at its native pixel size. - One of them: the other follows the aspect ratio.
"width": 400on a 1280×720 photo gives 400×225. - Both: the layer gets exactly that box, and
fitdecides how the picture fills it. - Percentages are of the parent:
"width": "100%", "height": "100%"fills the frame (or the group).
The layer's box (what the anchor refers to and what inspect reports) is always the width×height
box, whatever fit does inside it.
#Fit modes
{ "fonts": [{ "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }], "compositions": [{ "id": "fit", "description": "The same square SVG in three 300×170 boxes: cover, contain and fill", "width": 1280, "height": 720, "fps": 30, "duration": "3s", "background": "#f4f1ea", "layers": [ { "id": "frame", "type": "rect", "x": "=300 + i * 340", "y": "45%", "width": 300, "height": 170, "repeat": 3, "fill": "#e9e4d8", "stroke": "#16141288", "strokeWidth": 1.5, "dash": [6, 5] }, { "id": "cover", "type": "image", "src": "assets/logo.svg", "x": 300, "y": "45%", "width": 300, "height": 170, "fit": "cover", "enter": "fade" }, { "id": "contain", "type": "image", "src": "assets/logo.svg", "x": 640, "y": "45%", "width": 300, "height": 170, "fit": "contain", "start": "0.2s", "enter": "fade" }, { "id": "fill", "type": "image", "src": "assets/logo.svg", "x": 980, "y": "45%", "width": 300, "height": 170, "fit": "fill", "start": "0.4s", "enter": "fade" }, { "id": "label", "type": "text", "x": "=300 + i * 340", "y": "68%", "repeat": 3, "font": "JetBrains Mono", "fontSize": 20, "letterSpacing": 1.6, "fill": "#8a857a", "text": "fit: ${pick(i, ['cover', 'contain', 'fill'])}" } ] }]}fit | effect |
|---|---|
cover (default) | Scales the picture to fill the whole box and crops what overflows, centered. No empty space. |
contain | Scales the picture to fit entirely inside the box, centered. Leaves empty bands. |
fill | Stretches the picture to the box exactly. Distorts unless the aspect ratios match. (stretch is accepted as an alias.) |
none | Native pixel size, centered in the box and cropped to it. |
With contain, cornerRadius rounds the visible picture, not the empty bands. For a frame or a
backdrop behind a contained picture, put a rect of the same size under it.
#SVG stays sharp
An SVG is rasterized at the size it is displayed at (including the render --scale), so a 200×200
logo shown at 440 px has crisp edges instead of upscaled pixels:
{ "fonts": [{ "family": "JetBrains Mono", "path": "fonts/JetBrainsMono.ttf" }], "compositions": [{ "id": "svg", "description": "An SVG is rasterized at its displayed size, so a 200×200 logo stays sharp at 440×440", "width": 1280, "height": 720, "fps": 30, "duration": "4s", "background": "#f4f1ea", "layers": [ { "id": "logo", "type": "image", "src": "assets/logo.svg", "y": "44%", "width": 440, "scale": { "from": 0.3, "to": 1, "duration": "1s", "spring": { "damping": 12, "stiffness": 120 } }, "rotation": "=4 * sin(t * pi)", "shadow": { "color": "#16141226", "blur": 24, "y": 14 } }, { "id": "caption", "type": "text", "y": "88%", "font": "JetBrains Mono", "fontSize": 18, "letterSpacing": 1.6, "fill": "#8a857a", "text": "logo.svg · 200×200 source · width 440", "start": "0.6s", "enter": "fadeUp" } ] }]}The size used for rasterizing is the layer's width/height at its first frame. Set width/height
to the largest size the logo will appear at and animate scale up to 1 (as the demo does), rather than
animating width upward: scaling the rendered logo down stays sharp, scaling it up does not.
SVG files are rendered by resvg: gradients, masks, filters, embedded images and text all work. Text inside an SVG uses the system fonts; convert it to outlines in your design tool if the font is not installed where you render.
#Theming an SVG: svgVars
Icon sets from design systems usually color their strokes with currentColor and their accents with CSS
variables, such as style="fill: var(--accent, #c92a26)", so the page can theme them. vidmake renders such
files with the fallback color, and svgVars sets the values per layer: one icon file, any theme.
{ "compositions": [{ "id": "themes", "description": "One SVG icon, three themes: svgVars sets currentColor and the CSS variable --accent per layer", "width": 1280, "height": 720, "fps": 30, "duration": "3s", "background": "#f4f1ea", "layers": [ { "id": "tile-ivory", "type": "rect", "width": 320, "height": 320, "x": 290, "y": 360, "fill": "#fbf9f4", "stroke": "#161412" }, { "id": "icon-ivory", "type": "image", "src": "icons/ship.svg", "width": 200, "x": 290, "y": 360, "svgVars": { "currentColor": "#161412", "--accent": "#c92a26" }, "enter": "pop" }, { "id": "tile-dark", "type": "rect", "width": 320, "height": 320, "x": 640, "y": 360, "fill": "#161412" }, { "id": "icon-dark", "type": "image", "src": "icons/ship.svg", "width": 200, "x": 640, "y": 360, "svgVars": { "currentColor": "#efebe2", "--accent": "#6aa6e8" }, "start": "0.2s", "enter": "pop" }, { "id": "tile-gold", "type": "rect", "width": 320, "height": 320, "x": 990, "y": 360, "fill": "#c92a26" }, { "id": "icon-gold", "type": "image", "src": "icons/ship.svg", "width": 200, "x": 990, "y": 360, "svgVars": { "currentColor": "#161412", "--accent": "#fbf9f4" }, "start": "0.4s", "enter": "pop" } ] }]}{ "id": "icon-dark", "type": "image", "src": "icons/ship.svg", "width": 200, "svgVars": { "currentColor": "#efebe2", "--accent": "#6aa6e8" } }Keys are CSS variable names ("--accent") or "currentColor"; values are colors. They are applied when the
SVG is rasterized, so they are fixed for the layer (not animatable); to fade between themes, stack two layers
and cross-fade them. To show a different file per copy of a repeated
layer, use ${...} in src.
#Recipes
Full-frame background photo, dimmed so text reads on top:
{ "id": "bg", "type": "image", "src": "photo.jpg", "width": "100%", "height": "100%", "brightness": 0.6 }Ken Burns (slow push-in): cover hides the edges while scale grows from the center.
{ "id": "photo", "type": "image", "src": "photo.jpg", "width": "100%", "height": "100%", "scale": { "from": 1, "to": 1.15, "duration": "6s", "ease": "linear" } }Circular avatar with a ring:
{ "id": "avatar", "type": "image", "src": "ada.jpg", "width": 160, "height": 160, "cornerRadius": "50%" },{ "id": "avatar-ring", "type": "ellipse", "width": 172, "fill": null, "stroke": "#161412", "strokeWidth": 4 }Black-and-white that blooms into color: animate saturation from 0 to 1.
A photo through text (the image visible only inside the letters) is a mask. A slideshow of photos with transitions is a series. More in Recipes.