Imgcli

完整场景

前后对比

同一画面中的两个版本:滑块扫过画面揭开第二个版本,略微越过后折返,最后停在中间,让两边都清楚可见。

制作视频
类型
动画
时长
4.4s
分类
完整场景
来源
Imgcli

安装

$ npx @imgcli/cli add before-after

同一画面中的两个版本:滑块扫过画面揭开第二个版本,略微越过后折返,最后停在中间,让两边都清楚可见。

安装

npx @imgcli/cli add before-after

使用

import { BeforeAfter } from "@/components/imgcli/before-after";

<BeforeAfter />

默认参数下以 30 fps 渲染 132 帧(4.4 秒),预览画布为 960 × 540。

Use <BeforeAfter before="/old.png" after="/new.png" beforeLabel="Before" afterLabel="After" /> for 132 frames at 30 fps (BEFORE_AFTER_SECONDS). Both images share one framing.

参数类型默认值说明
before
stringlightPageTwo images of the same framing; the slider uncovers `after` from the right.
after
stringdarkPage
beforeLabel
string"Light"
afterLabel
string"Dark"
aspect
number1.6Width ÷ height of both images.
title
string"One theme prop, both modes."
fontFamily
string—A face from the Imgcli font list, or any loaded CSS font stack.
accentColor
string—
theme
Partial<ImgcliTheme>—
mode
"light" | "dark"—
speed
number1

许可

MIT 许可,可免费用于个人及商业项目,保留版权和许可声明。

Copyright (c) 2026 Ricky (Imgcli) <https://imgcli.com>

常见问题

如何在 Remotion 项目中使用前后对比?

运行 npx @imgcli/cli add before-after。CLI 会把组件源码复制到项目的 components/imgcli/ 目录并安装依赖,之后可以直接修改源码。

前后对比能做什么?

同一画面中的两个版本:滑块扫过画面揭开第二个版本,略微越过后折返,最后停在中间,让两边都清楚可见。

使用前后对比前需要准备什么?

准备 Node.js 20.19 或更高版本,以及一个 Remotion 项目。新项目可以用 npx create-video@latest 创建。免费组件采用 MIT 许可证。