Open source CapCut alternative.
TypeScript
fix(site): shape share cards to the cut's own aspect
David Le3b98334d273d
diff --git a/site/src/app/cut/s/[token]/page.tsx b/site/src/app/cut/s/[token]/page.tsxindex 910c23e9..9b86d0d9 100644--- a/site/src/app/cut/s/[token]/page.tsx+++ b/site/src/app/cut/s/[token]/page.tsx@@ -51,9 +51,13 @@ export async function generateMetadata({// the rest fall back to its first frame — the same picture the JPEG carries// for anything that would rather not take a multi-megabyte image. Either URL// answers before a card has rendered; the route draws one.+ //+ // No declared dimensions: a card is the cut's own shape (a portrait project+ // unfurls portrait) and the drawn placeholder is 1.91:1, so any number here+ // would be wrong for some shares and platforms lay out against it.const images = [- { url: card("gif"), width: 1200, height: 630, alt: meta.name },- { url: card("jpg"), width: 1200, height: 630, alt: meta.name },+ { url: card("gif"), alt: meta.name },+ { url: card("jpg"), alt: meta.name },];return {title: `${meta.name} · Donkey Cut`,diff --git a/site/src/cut/worker/cardJob.ts b/site/src/cut/worker/cardJob.tsindex 8b1f9cd7..806f11f3 100644--- a/site/src/cut/worker/cardJob.ts+++ b/site/src/cut/worker/cardJob.ts@@ -13,11 +13,14 @@ import { cardKey, uploadFile } from "./r2";// the first frame, which is the same picture either way./** Animated card: small enough that no crawler refuses it, big enough to read- * on a phone. Tried in order until one lands under MAX_GIF_BYTES. */+ * on a phone. Tried in order until one lands under MAX_GIF_BYTES. `box` is the+ * longest side, not the width — sizing a portrait cut by width gives it three+ * times the area of a landscape one at the same setting, and a GIF's size+ * tracks its area. */const GIF_RECIPES = [- { fps: 12, width: 600, colors: 128 },- { fps: 10, width: 480, colors: 96 },- { fps: 8, width: 400, colors: 64 },+ { fps: 12, box: 600, colors: 128 },+ { fps: 10, box: 480, colors: 96 },+ { fps: 8, box: 400, colors: 64 },];const MAX_GIF_BYTES = 3 * 1024 * 1024;@@ -65,7 +68,8 @@ async function renderAnimation(source: string, dest: string): Promise<number> {"-i",source,"-vf",- `fps=${recipe.fps},scale=${recipe.width}:-2:flags=lanczos,split[s0][s1];` ++ `fps=${recipe.fps},scale=w=${recipe.box}:h=${recipe.box}:` ++ `force_original_aspect_ratio=decrease:flags=lanczos,split[s0][s1];` +`[s0]palettegen=max_colors=${recipe.colors}[p];[s1][p]paletteuse=dither=bayer:bayer_scale=3`,"-loop","0",