add webp thumbnail support

This commit is contained in:
2024-10-24 12:48:39 +08:00
parent aec2505786
commit da291d234c
9 changed files with 72 additions and 14 deletions

View File

@@ -1,3 +1,4 @@
import { ThumbnailFormat } from "../config.ts";
import { ThumbnailAlign } from "./base.ts";
import { type ThumbnailConfig, ThumbnailGenMethod } from "./base.ts";
@@ -45,8 +46,10 @@ export async function fb_generate_thumbnail(
i: string,
o: string,
cfg: ThumbnailConfig,
fmt: ThumbnailFormat,
) {
let add = "";
const codec = fmt == ThumbnailFormat.WEBP ? "libwebp" : "mjpeg";
if (cfg.method == ThumbnailGenMethod.Cover) {
const size = cfg.input ?? await fb_get_size(i);
if (!size) return false;
@@ -90,6 +93,8 @@ export async function fb_generate_thumbnail(
"-n",
"-i",
i,
"-c",
codec,
"-vf",
add,
"-qmin",