OpenReel Video - Professional browser-based video editor. Open source CapCut alternative. 100% browser-based, no installation, no cloud uploads, no watermarks.
TypeScript
fix(editor): preserve original asset dimensions and add white balance controls (#63)
Augustus Otu33bc120cca72
diff --git a/apps/web/src/bridges/effects-bridge.ts b/apps/web/src/bridges/effects-bridge.tsindex 67645bc1..ed945be2 100644--- a/apps/web/src/bridges/effects-bridge.ts+++ b/apps/web/src/bridges/effects-bridge.ts@@ -57,6 +57,10 @@ export interface ColorGradingSettings {curves?: CurvesValues;lut?: LUTData;hsl?: HSLValues;+ /** Temperature shift in range [-100, 100]. Negative = cool/blue, positive = warm/orange */+ temperature?: number;+ /** Tint shift in range [-100, 100]. Negative = green, positive = magenta */+ tint?: number;}/**@@ -92,6 +96,8 @@ export interface SerializedColorGrading {intensity: number;};hsl?: HSLValues;+ temperature?: number;+ tint?: number;}/**@@ -613,6 +619,33 @@ export class EffectsBridge {return { success: true };}+ /**+ * Apply white balance (temperature + tint) for a clip.+ *+ * @param clipId - The clip to apply white balance to+ * @param values - Temperature ([-100, 100]) and tint ([-100, 100])+ * @returns Application result+ */+ applyWhiteBalance(+ clipId: string,+ values: { temperature?: number; tint?: number },+ ): EffectResult {+ if (!this.initialized) {+ return { success: false, error: "EffectsBridge not initialized" };+ }++ const colorGrading = this.clipColorGrading.get(clipId) || {};+ if (values.temperature !== undefined) {+ colorGrading.temperature = values.temperature;+ }+ if (values.tint !== undefined) {+ colorGrading.tint = values.tint;+ }+ this.clipColorGrading.set(clipId, colorGrading);++ return { success: true };+ }+/*** Get color grading settings for a clip*@@ -638,6 +671,8 @@ export class EffectsBridge {colorWheels: { ...DEFAULT_COLOR_WHEELS },curves: { ...DEFAULT_CURVES },hsl: { ...DEFAULT_HSL },+ temperature: 0,+ tint: 0,});return { success: true };@@ -702,6 +737,51 @@ export class EffectsBridge {totalTime += result.processingTime;}+ // Apply white balance (temperature + tint) via VideoEffectsEngine+ const whiteBalanceEffects: Effect[] = [];+ if (+ this.videoEffectsEngine &&+ settings.temperature !== undefined &&+ settings.temperature !== 0+ ) {+ whiteBalanceEffects.push({+ id: "wb-temperature",+ type: "temperature",+ enabled: true,+ params: { value: settings.temperature },+ });+ }+ if (+ this.videoEffectsEngine &&+ settings.tint !== undefined &&+ settings.tint !== 0+ ) {+ whiteBalanceEffects.push({+ id: "wb-tint",+ type: "tint",+ enabled: true,+ params: { value: settings.tint },+ });+ }+ if (whiteBalanceEffects.length > 0 && this.videoEffectsEngine) {+ try {+ const result = await this.videoEffectsEngine.applyEffects(+ currentImage,+ whiteBalanceEffects,+ );+ if (+ result.image &&+ result.image.width > 0 &&+ result.image.height > 0+ ) {+ currentImage = result.image;+ totalTime += result.processingTime;+ }+ } catch (error) {+ console.warn("[EffectsBridge] White balance processing failed:", error);+ }+ }+return { image: currentImage, processingTime: totalTime };}@@ -812,6 +892,14 @@ export class EffectsBridge {serializedColorGrading.hsl = colorGrading.hsl;}+ if (colorGrading.temperature !== undefined) {+ serializedColorGrading.temperature = colorGrading.temperature;+ }++ if (colorGrading.tint !== undefined) {+ serializedColorGrading.tint = colorGrading.tint;+ }+return { effects: serializedEffects, colorGrading: serializedColorGrading };}@@ -868,6 +956,14 @@ export class EffectsBridge {colorGrading.hsl = data.colorGrading.hsl;}+ if (data.colorGrading.temperature !== undefined) {+ colorGrading.temperature = data.colorGrading.temperature;+ }++ if (data.colorGrading.tint !== undefined) {+ colorGrading.tint = data.colorGrading.tint;+ }+this.clipColorGrading.set(clipId, colorGrading);return { success: true };diff --git a/apps/web/src/components/editor/InspectorPanel.tsx b/apps/web/src/components/editor/InspectorPanel.tsxindex 01ab38d5..57dd313b 100644--- a/apps/web/src/components/editor/InspectorPanel.tsx+++ b/apps/web/src/components/editor/InspectorPanel.tsx@@ -1319,14 +1319,14 @@ export const InspectorPanel: React.FC = () => {step={1}unit="px"/>- {clipType === "image" && (+ {(clipType === "image" || clipType === "video") && (<div className="space-y-1 pt-2 border-t border-border"><span className="text-[10px] text-text-secondary">Fit Mode</span><div className="grid grid-cols-4 gap-1">{(- ["contain", "cover", "stretch", "none"] as FitMode[]+ ["none", "contain", "cover", "stretch"] as FitMode[]).map((mode) => (<buttonkey={mode}@@ -1343,7 +1343,9 @@ export const InspectorPanel: React.FC = () => {? "Fit": mode === "cover"? "Fill"- : mode}+ : mode === "none"+ ? "Original"+ : mode}</button>))}</div>diff --git a/apps/web/src/components/editor/Preview.tsx b/apps/web/src/components/editor/Preview.tsxindex 5edd24ab..7d00faac 100644--- a/apps/web/src/components/editor/Preview.tsx+++ b/apps/web/src/components/editor/Preview.tsx@@ -4676,8 +4676,42 @@ export const Preview: React.FC = () => {const displayScale = actualWidth / canvasWidth;- const clipWidth = canvasWidth * transform.scale.x * displayScale;- const clipHeight = canvasHeight * transform.scale.y * displayScale;+ const fitMode = clipTransform.fitMode ?? "contain";+ const mediaItem = getMediaItem(clip.mediaId);+ const mediaWidth = mediaItem?.metadata?.width ?? canvasWidth;+ const mediaHeight = mediaItem?.metadata?.height ?? canvasHeight;++ let baseWidth: number;+ let baseHeight: number;++ if (fitMode === "none") {+ baseWidth = mediaWidth;+ baseHeight = mediaHeight;+ } else if (fitMode === "stretch") {+ baseWidth = canvasWidth;+ baseHeight = canvasHeight;+ } else if (fitMode === "cover") {+ const mediaAspect = mediaWidth / mediaHeight;+ if (mediaAspect > canvasAspect) {+ baseHeight = canvasHeight;+ baseWidth = canvasHeight * mediaAspect;+ } else {+ baseWidth = canvasWidth;+ baseHeight = canvasWidth / mediaAspect;+ }+ } else {+ const mediaAspect = mediaWidth / mediaHeight;+ if (mediaAspect > canvasAspect) {+ baseWidth = canvasWidth;+ baseHeight = canvasWidth / mediaAspect;+ } else {+ baseHeight = canvasHeight;+ baseWidth = canvasHeight * mediaAspect;+ }+ }++ const clipWidth = baseWidth * transform.scale.x * displayScale;+ const clipHeight = baseHeight * transform.scale.y * displayScale;const offsetX = transform.position.x * displayScale;const offsetY = transform.position.y * displayScale;@@ -4704,6 +4738,7 @@ export const Preview: React.FC = () => {settings.height,canvasSize,liveTransform,+ getMediaItem,]);const textClipBounds = useMemo(() => {@@ -5452,8 +5487,17 @@ export const Preview: React.FC = () => {let newX = startTransform.x;let newY = startTransform.y;- const scaleDeltaX = deltaX / displayScale / (settings.width / 2);- const scaleDeltaY = deltaY / displayScale / (settings.height / 2);+ // Base dimensions match how the clip is actually rendered so resize+ // handles track the cursor regardless of fit mode.+ const baseScaleW =+ (clipBounds.width / displayScale) /+ Math.max(0.001, startTransform.scaleX);+ const baseScaleH =+ (clipBounds.height / displayScale) /+ Math.max(0.001, startTransform.scaleY);++ const scaleDeltaX = deltaX / displayScale / (baseScaleW / 2);+ const scaleDeltaY = deltaY / displayScale / (baseScaleH / 2);switch (activeHandle) {case "e":diff --git a/apps/web/src/components/editor/dialogs/AspectRatioMatchDialog.tsx b/apps/web/src/components/editor/dialogs/AspectRatioMatchDialog.tsxindex d28f30ae..adc6b7a3 100644--- a/apps/web/src/components/editor/dialogs/AspectRatioMatchDialog.tsx+++ b/apps/web/src/components/editor/dialogs/AspectRatioMatchDialog.tsx@@ -80,8 +80,9 @@ export const AspectRatioMatchDialog: React.FC<AspectRatioMatchDialogProps> = ({</div><p className="text-xs text-text-tertiary">- Updating the project dimensions will provide the best editing- experience and prevent cropping during export.+ Match the project dimensions to this video for a clean fit, or keep+ the current canvas — your video will be placed at its original size+ so you can resize it freely.</p></div>diff --git a/apps/web/src/components/editor/inspector/ColorGradingSection.tsx b/apps/web/src/components/editor/inspector/ColorGradingSection.tsxindex 57f2783f..895125a3 100644--- a/apps/web/src/components/editor/inspector/ColorGradingSection.tsx+++ b/apps/web/src/components/editor/inspector/ColorGradingSection.tsx@@ -1,5 +1,6 @@import React, { useCallback, useMemo } from "react";-import { ChevronDown, RotateCcw } from "lucide-react";+import { ChevronDown, RotateCcw, Sun, Thermometer } from "lucide-react";+import { LabeledSlider } from "@openreel/ui";import { useProjectStore } from "../../../stores/project-store";import type {ColorWheelValues,@@ -17,6 +18,18 @@ import { CurvesEditor } from "./CurvesEditor";import { LUTLoader } from "./LUTLoader";import { HSLControls } from "./HSLControls";+const WHITE_BALANCE_PRESETS: Array<{+ label: string;+ temperature: number;+ tint: number;+}> = [+ { label: "Tungsten", temperature: -40, tint: 8 },+ { label: "Fluorescent", temperature: -15, tint: -10 },+ { label: "Daylight", temperature: 0, tint: 0 },+ { label: "Cloudy", temperature: 15, tint: 0 },+ { label: "Shade", temperature: 30, tint: 5 },+];+const SubSection: React.FC<{title: string;defaultOpen?: boolean;@@ -75,6 +88,37 @@ export const ColorGradingSection: React.FC<ColorGradingSectionProps> = ({return colorGrading.curves || { ...DEFAULT_CURVES };}, [colorGrading.curves]);+ const temperatureValue = colorGrading.temperature ?? 0;+ const tintValue = colorGrading.tint ?? 0;++ const handleTemperatureChange = useCallback(+ (value: number) => {+ updateColorGrading(clipId, { temperature: value });+ },+ [clipId, updateColorGrading],+ );++ const handleTintChange = useCallback(+ (value: number) => {+ updateColorGrading(clipId, { tint: value });+ },+ [clipId, updateColorGrading],+ );++ const handleWhiteBalanceReset = useCallback(() => {+ updateColorGrading(clipId, { temperature: 0, tint: 0 });+ }, [clipId, updateColorGrading]);++ const handleWhiteBalancePreset = useCallback(+ (preset: { temperature: number; tint: number }) => {+ updateColorGrading(clipId, {+ temperature: preset.temperature,+ tint: preset.tint,+ });+ },+ [clipId, updateColorGrading],+ );+const handleColorWheelsChange = useCallback((values: ColorWheelValues) => {updateColorGrading(clipId, { colorWheels: values });@@ -131,7 +175,97 @@ export const ColorGradingSection: React.FC<ColorGradingSectionProps> = ({</button></div>- <SubSection title="Color Wheels" defaultOpen>+ <SubSection title="White Balance" defaultOpen>+ <div className="space-y-4">+ <div className="flex items-start justify-between gap-2">+ <p className="text-[10px] text-text-muted leading-snug">+ Warm up cool shots or cool down warm ones. Tint corrects green or+ magenta casts.+ </p>+ <button+ onClick={handleWhiteBalanceReset}+ className="flex items-center gap-1 px-2 py-0.5 text-[10px] text-text-muted hover:text-text-primary transition-colors shrink-0"+ title="Reset white balance"+ >+ <RotateCcw size={10} />+ Reset+ </button>+ </div>++ <div className="space-y-2">+ <div className="flex items-center gap-1.5">+ <Thermometer size={12} className="text-text-muted" />+ <LabeledSlider+ label="Temperature"+ value={temperatureValue}+ onChange={handleTemperatureChange}+ min={-100}+ max={100}+ step={1}+ className="flex-1"+ />+ </div>+ <div className="h-1 rounded-full pointer-events-none mx-5"+ style={{+ background:+ "linear-gradient(to right, #4aa8ff 0%, #cccccc 50%, #ff9a3c 100%)",+ opacity: 0.7,+ }}+ />+ </div>++ <div className="space-y-2">+ <div className="flex items-center gap-1.5">+ <Sun size={12} className="text-text-muted" />+ <LabeledSlider+ label="Tint"+ value={tintValue}+ onChange={handleTintChange}+ min={-100}+ max={100}+ step={1}+ className="flex-1"+ />+ </div>+ <div className="h-1 rounded-full pointer-events-none mx-5"+ style={{+ background:+ "linear-gradient(to right, #4ad17f 0%, #cccccc 50%, #d44ad1 100%)",+ opacity: 0.7,+ }}+ />+ </div>++ <div className="pt-1">+ <span className="text-[10px] text-text-muted block mb-1.5">+ Presets+ </span>+ <div className="grid grid-cols-5 gap-1">+ {WHITE_BALANCE_PRESETS.map((preset) => {+ const isActive =+ Math.abs(preset.temperature - temperatureValue) < 0.5 &&+ Math.abs(preset.tint - tintValue) < 0.5;+ return (+ <button+ key={preset.label}+ onClick={() => handleWhiteBalancePreset(preset)}+ className={`py-1 rounded text-[9px] transition-colors ${+ isActive+ ? "bg-primary text-white"+ : "bg-background-tertiary border border-border text-text-secondary hover:text-text-primary"+ }`}+ title={`Temp: ${preset.temperature}, Tint: ${preset.tint}`}+ >+ {preset.label}+ </button>+ );+ })}+ </div>+ </div>+ </div>+ </SubSection>++ <SubSection title="Color Wheels" defaultOpen={false}><ColorWheelsControlvalues={colorWheelValues}onChange={handleColorWheelsChange}diff --git a/apps/web/src/components/editor/inspector/ColorWheelsControl.tsx b/apps/web/src/components/editor/inspector/ColorWheelsControl.tsxindex f8e1c04e..32a409ee 100644--- a/apps/web/src/components/editor/inspector/ColorWheelsControl.tsx+++ b/apps/web/src/components/editor/inspector/ColorWheelsControl.tsx@@ -98,8 +98,8 @@ const ColorWheel: React.FC<ColorWheelProps> = ({const angle = Math.atan2(y, x);return {- x: Math.cos(angle) * saturation * 28,- y: Math.sin(angle) * saturation * 28,+ x: Math.cos(angle) * saturation * 44,+ y: Math.sin(angle) * saturation * 44,saturation: Math.min(saturation, 1),};}, [color.r, color.b]);@@ -158,13 +158,13 @@ const ColorWheel: React.FC<ColorWheelProps> = ({}, [onReset]);return (- <div className="flex flex-col items-center gap-1.5">- <span className="text-[9px] text-text-muted uppercase tracking-wider font-medium">+ <div className="flex flex-col items-center gap-2">+ <span className="text-[10px] text-text-muted uppercase tracking-wider font-medium">{label}</span><divref={wheelRef}- className="w-16 h-16 rounded-full relative cursor-crosshair shadow-inner"+ className="w-24 h-24 rounded-full relative cursor-crosshair shadow-inner"style={{background: `conic-gradient(from 90deg,@@ -191,10 +191,10 @@ const ColorWheel: React.FC<ColorWheelProps> = ({/>{/* Indicator dot */}<div- className="absolute w-3 h-3 border-2 border-white rounded-full shadow-md pointer-events-none z-10"+ className="absolute w-4 h-4 border-2 border-white rounded-full shadow-md pointer-events-none z-10"style={{- left: `calc(50% + ${getPositionFromColor.x}px - 6px)`,- top: `calc(50% + ${getPositionFromColor.y}px - 6px)`,+ left: `calc(50% + ${getPositionFromColor.x}px - 8px)`,+ top: `calc(50% + ${getPositionFromColor.y}px - 8px)`,backgroundColor:getPositionFromColor.saturation > 0.1? `rgb(${128 + color.r * 127}, ${128 + color.g * 127}, ${diff --git a/apps/web/src/components/editor/preview/canvas-renderers.ts b/apps/web/src/components/editor/preview/canvas-renderers.tsindex 0019a323..e290424a 100644--- a/apps/web/src/components/editor/preview/canvas-renderers.ts+++ b/apps/web/src/components/editor/preview/canvas-renderers.ts@@ -1829,19 +1829,35 @@ export const drawFrameWithTransform = (sourceHeight = "height" in frame ? frame.height : canvasHeight;}- // Calculate draw size to fit frame within canvas while preserving aspect ratio (contain)const sourceAspect = sourceWidth / sourceHeight;const canvasAspect = canvasWidth / canvasHeight;+ const fitMode = t.fitMode ?? "contain";let drawWidth: number;let drawHeight: number;- if (sourceAspect > canvasAspect) {+ if (fitMode === "none") {+ drawWidth = sourceWidth;+ drawHeight = sourceHeight;+ } else if (fitMode === "stretch") {drawWidth = canvasWidth;- drawHeight = canvasWidth / sourceAspect;- } else {drawHeight = canvasHeight;- drawWidth = canvasHeight * sourceAspect;+ } else if (fitMode === "cover") {+ if (sourceAspect > canvasAspect) {+ drawHeight = canvasHeight;+ drawWidth = canvasHeight * sourceAspect;+ } else {+ drawWidth = canvasWidth;+ drawHeight = canvasWidth / sourceAspect;+ }+ } else {+ if (sourceAspect > canvasAspect) {+ drawWidth = canvasWidth;+ drawHeight = canvasWidth / sourceAspect;+ } else {+ drawHeight = canvasHeight;+ drawWidth = canvasHeight * sourceAspect;+ }}const drawX = -drawWidth * t.anchor.x;diff --git a/apps/web/src/components/editor/preview/types.ts b/apps/web/src/components/editor/preview/types.tsindex 92388932..e7c0da50 100644--- a/apps/web/src/components/editor/preview/types.ts+++ b/apps/web/src/components/editor/preview/types.ts@@ -2,6 +2,8 @@ export type HandlePosition = "nw" | "n" | "ne" | "e" | "se" | "s" | "sw" | "w";export type InteractionMode = "none" | "move" | "resize";+export type FitMode = "contain" | "cover" | "stretch" | "none";+export interface ClipTransform {position: { x: number; y: number };scale: { x: number; y: number };@@ -9,6 +11,7 @@ export interface ClipTransform {opacity: number;anchor: { x: number; y: number };borderRadius?: number;+ fitMode?: FitMode;crop?: {x: number;y: number;@@ -24,4 +27,5 @@ export const DEFAULT_TRANSFORM: ClipTransform = {opacity: 1,anchor: { x: 0.5, y: 0.5 },borderRadius: 0,+ fitMode: "none",};diff --git a/apps/web/src/components/editor/settings/GeneralPanel.tsx b/apps/web/src/components/editor/settings/GeneralPanel.tsxindex 8ee8323a..d4e73917 100644--- a/apps/web/src/components/editor/settings/GeneralPanel.tsx+++ b/apps/web/src/components/editor/settings/GeneralPanel.tsx@@ -1,7 +1,18 @@-import React from "react";+import React, { useCallback } from "react";import { Switch } from "@openreel/ui";import { Label } from "@openreel/ui";import { useSettingsStore, SERVICE_REGISTRY, type TtsProvider, type LlmProvider, type AggregatorProvider } from "../../../stores/settings-store";+import { useProjectStore } from "../../../stores/project-store";++const ASPECT_PRESETS: Array<{ label: string; width: number; height: number }> = [+ { label: "16:9 Landscape (1080p)", width: 1920, height: 1080 },+ { label: "9:16 Vertical (TikTok/Reels)", width: 1080, height: 1920 },+ { label: "1:1 Square", width: 1080, height: 1080 },+ { label: "4:5 Portrait", width: 1080, height: 1350 },+ { label: "4:3 Standard", width: 1440, height: 1080 },+ { label: "21:9 Cinematic", width: 2560, height: 1080 },+ { label: "4K Landscape", width: 3840, height: 2160 },+];export const GeneralPanel: React.FC = () => {const {@@ -18,6 +29,35 @@ export const GeneralPanel: React.FC = () => {setDefaultAggregator,} = useSettingsStore();+ const projectWidth = useProjectStore((s) => s.project.settings.width);+ const projectHeight = useProjectStore((s) => s.project.settings.height);+ const updateProjectSettings = useProjectStore((s) => s.updateSettings);++ const [draftWidth, setDraftWidth] = React.useState(String(projectWidth));+ const [draftHeight, setDraftHeight] = React.useState(String(projectHeight));++ React.useEffect(() => {+ setDraftWidth(String(projectWidth));+ setDraftHeight(String(projectHeight));+ }, [projectWidth, projectHeight]);++ const applyDimensions = useCallback(+ async (width: number, height: number) => {+ const w = Math.max(16, Math.min(7680, Math.round(width)));+ const h = Math.max(16, Math.min(7680, Math.round(height)));+ await updateProjectSettings({ width: w, height: h });+ },+ [updateProjectSettings],+ );++ const handleApplyCustom = useCallback(() => {+ const w = Number(draftWidth);+ const h = Number(draftHeight);+ if (Number.isFinite(w) && Number.isFinite(h) && w > 0 && h > 0) {+ applyDimensions(w, h);+ }+ }, [draftWidth, draftHeight, applyDimensions]);+const ttsProviders = [{ id: "piper", label: "Piper (Free / Built-in)" },...SERVICE_REGISTRY.filter(@@ -41,6 +81,75 @@ export const GeneralPanel: React.FC = () => {return (<div className="space-y-6 pb-4">+ {/* Project Composition */}+ <div className="space-y-4">+ <div>+ <h3 className="text-sm font-medium text-text-primary">+ Project Composition+ </h3>+ <p className="text-xs text-text-muted mt-0.5">+ Set the canvas dimensions for your project. Pick a preset for TikTok,+ Reels, YouTube, or enter custom values.+ </p>+ </div>++ <div className="grid grid-cols-2 gap-2">+ {ASPECT_PRESETS.map((preset) => {+ const isActive =+ preset.width === projectWidth && preset.height === projectHeight;+ return (+ <button+ key={preset.label}+ onClick={() => applyDimensions(preset.width, preset.height)}+ className={`text-left px-3 py-2 rounded-md text-xs transition-colors border ${+ isActive+ ? "border-primary bg-primary/10 text-text-primary"+ : "border-border bg-background-tertiary text-text-secondary hover:text-text-primary hover:border-primary/40"+ }`}+ >+ <div className="font-medium">{preset.label}</div>+ <div className="text-text-muted text-[10px] mt-0.5">+ {preset.width} × {preset.height}+ </div>+ </button>+ );+ })}+ </div>++ <div className="flex items-end gap-2">+ <div className="flex-1">+ <Label className="text-xs text-text-secondary">Width</Label>+ <input+ type="number"+ min={16}+ max={7680}+ value={draftWidth}+ onChange={(e) => setDraftWidth(e.target.value)}+ className="mt-1 h-9 w-full rounded-md border border-input bg-background px-3 text-sm"+ />+ </div>+ <div className="flex-1">+ <Label className="text-xs text-text-secondary">Height</Label>+ <input+ type="number"+ min={16}+ max={7680}+ value={draftHeight}+ onChange={(e) => setDraftHeight(e.target.value)}+ className="mt-1 h-9 w-full rounded-md border border-input bg-background px-3 text-sm"+ />+ </div>+ <button+ onClick={handleApplyCustom}+ className="h-9 px-3 rounded-md bg-primary text-white text-xs font-medium hover:bg-primary/90 transition-colors"+ >+ Apply+ </button>+ </div>+ </div>++ <div className="h-px bg-border" />+{/* Auto-save */}<div className="space-y-4"><h3 className="text-sm font-medium text-text-primary">Auto-Save</h3>diff --git a/apps/web/src/stores/project-store.ts b/apps/web/src/stores/project-store.tsindex 154c0fc6..c1ddfe5a 100644--- a/apps/web/src/stores/project-store.ts+++ b/apps/web/src/stores/project-store.ts@@ -5537,6 +5537,20 @@ export const useProjectStore = create<ProjectState>()(}}+ if (+ settings.temperature !== undefined ||+ settings.tint !== undefined+ ) {+ const result = effectsBridge.applyWhiteBalance(clipId, {+ temperature: settings.temperature,+ tint: settings.tint,+ });+ if (!result.success) {+ console.error("Failed to apply white balance:", result.error);+ return false;+ }+ }+// Trigger re-render by updating project stateset({ project: { ...get().project, modifiedAt: Date.now() } });return true;diff --git a/packages/core/src/actions/action-executor.ts b/packages/core/src/actions/action-executor.tsindex 96466049..749eb83e 100644--- a/packages/core/src/actions/action-executor.ts+++ b/packages/core/src/actions/action-executor.ts@@ -490,6 +490,7 @@ export class ActionExecutor {rotation: 0,anchor: { x: 0.5, y: 0.5 },opacity: 1,+ fitMode: "none" as const,},volume: 1,keyframes: [],diff --git a/packages/core/src/video/video-engine.ts b/packages/core/src/video/video-engine.tsindex 9a08f5ad..9a6dedd6 100644--- a/packages/core/src/video/video-engine.ts+++ b/packages/core/src/video/video-engine.ts@@ -970,9 +970,38 @@ export class VideoEngine {cropDrawHeight,);} else {- const drawX = -frame.width * transform.anchor.x;- const drawY = -frame.height * transform.anchor.y;- ctx.drawImage(frame, drawX, drawY);+ const fitMode = transform.fitMode ?? "none";+ let drawWidth = frame.width;+ let drawHeight = frame.height;++ if (fitMode !== "none") {+ const sourceAspect = frame.width / frame.height;+ const canvasAspect = canvasWidth / canvasHeight;+ if (fitMode === "stretch") {+ drawWidth = canvasWidth;+ drawHeight = canvasHeight;+ } else if (fitMode === "cover") {+ if (sourceAspect > canvasAspect) {+ drawHeight = canvasHeight;+ drawWidth = canvasHeight * sourceAspect;+ } else {+ drawWidth = canvasWidth;+ drawHeight = canvasWidth / sourceAspect;+ }+ } else {+ if (sourceAspect > canvasAspect) {+ drawWidth = canvasWidth;+ drawHeight = canvasWidth / sourceAspect;+ } else {+ drawHeight = canvasHeight;+ drawWidth = canvasHeight * sourceAspect;+ }+ }+ }++ const drawX = -drawWidth * transform.anchor.x;+ const drawY = -drawHeight * transform.anchor.y;+ ctx.drawImage(frame, drawX, drawY, drawWidth, drawHeight);}ctx.restore();@@ -2290,9 +2319,38 @@ export class VideoEngine {cropDrawHeight,);} else {- const drawX = -frame.width * transform.anchor.x;- const drawY = -frame.height * transform.anchor.y;- ctx.drawImage(frame, drawX, drawY);+ const fitMode = transform.fitMode ?? "none";+ let drawWidth = frame.width;+ let drawHeight = frame.height;++ if (fitMode !== "none") {+ const sourceAspect = frame.width / frame.height;+ const canvasAspect = canvasWidth / canvasHeight;+ if (fitMode === "stretch") {+ drawWidth = canvasWidth;+ drawHeight = canvasHeight;+ } else if (fitMode === "cover") {+ if (sourceAspect > canvasAspect) {+ drawHeight = canvasHeight;+ drawWidth = canvasHeight * sourceAspect;+ } else {+ drawWidth = canvasWidth;+ drawHeight = canvasWidth / sourceAspect;+ }+ } else {+ if (sourceAspect > canvasAspect) {+ drawWidth = canvasWidth;+ drawHeight = canvasWidth / sourceAspect;+ } else {+ drawHeight = canvasHeight;+ drawWidth = canvasHeight * sourceAspect;+ }+ }+ }++ const drawX = -drawWidth * transform.anchor.x;+ const drawY = -drawHeight * transform.anchor.y;+ ctx.drawImage(frame, drawX, drawY, drawWidth, drawHeight);}ctx.restore();