mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-06-06 05:38:44 +08:00
Bug fix
This commit is contained in:
@@ -2,7 +2,11 @@ import { Handlers } from "$fresh/server.ts";
|
||||
import { exists } from "std/fs/exists.ts";
|
||||
import { get_task_manager } from "../../server.ts";
|
||||
import { parse_int } from "../../server/parse_form.ts";
|
||||
import { generate_filename, ThumbnailConfig } from "../../thumbnail/base.ts";
|
||||
import {
|
||||
generate_filename,
|
||||
ThumbnailConfig,
|
||||
ThumbnailGenMethod,
|
||||
} from "../../thumbnail/base.ts";
|
||||
import { sure_dir } from "../../utils.ts";
|
||||
import {
|
||||
get_file_response,
|
||||
@@ -50,23 +54,28 @@ export const handler: Handlers = {
|
||||
const width = await parse_int(u.searchParams.get("width"), null);
|
||||
const height = await parse_int(u.searchParams.get("height"), null);
|
||||
const quality = await parse_int(u.searchParams.get("quality"), 1);
|
||||
const cfg: ThumbnailConfig = { width: 0, height: 0, quality };
|
||||
const cfg: ThumbnailConfig = {
|
||||
width: 0,
|
||||
height: 0,
|
||||
quality,
|
||||
method: ThumbnailGenMethod.Unknown,
|
||||
};
|
||||
if (width !== null && height !== null) {
|
||||
cfg.width = width;
|
||||
cfg.height = height;
|
||||
} else if (width !== null) {
|
||||
cfg.width = width;
|
||||
cfg.height = Math.round(f.height / f.width * width);
|
||||
cfg.height = Math.floor(f.height / f.width * width);
|
||||
} else if (height !== null) {
|
||||
cfg.height = height;
|
||||
cfg.width = Math.round(f.width / f.height * height);
|
||||
cfg.width = Math.floor(f.width / f.height * height);
|
||||
} else {
|
||||
if (f.width > f.height) {
|
||||
cfg.width = max;
|
||||
cfg.height = Math.round(f.height / f.width * max);
|
||||
cfg.height = Math.floor(f.height / f.width * max);
|
||||
} else {
|
||||
cfg.height = max;
|
||||
cfg.width = Math.round(f.width / f.height * max);
|
||||
cfg.width = Math.floor(f.width / f.height * max);
|
||||
}
|
||||
}
|
||||
const output = generate_filename(b, f, cfg);
|
||||
|
||||
Reference in New Issue
Block a user