Update /api/thumbnail

This commit is contained in:
2023-08-27 09:37:37 +08:00
parent 289ea9586c
commit 0cbb48d019
7 changed files with 149 additions and 35 deletions

View File

@@ -1,6 +1,6 @@
/// <reference lib="deno.unstable" />
import { Struct } from "pwn/mod.ts";
import { ThumbnailAlign, ThumbnailGenMethod } from "./base.ts";
import { ThumbnailAlign, ThumbnailConfig, ThumbnailGenMethod } from "./base.ts";
let libSuffix = "";
let libPrefix = "lib";
@@ -78,3 +78,25 @@ export async function gen_thumbnail(
if (re.e) return get_error(ore);
return;
}
export async function fa_generate_thumbnail(
i: string,
o: string,
cfg: ThumbnailConfig,
) {
let method = cfg.method;
if (method === ThumbnailGenMethod.Unknown) method = ThumbnailGenMethod.Fill;
const re = await gen_thumbnail(
i,
o,
cfg.width,
cfg.height,
method,
cfg.align,
cfg.quality,
);
if (re) {
console.error(re);
}
return re === undefined;
}