wip fix
This commit is contained in:
parent
ae6f89bfff
commit
e8a8ad56e5
|
|
@ -16,7 +16,7 @@ export const _ = {
|
||||||
|
|
||||||
const w = parseInt(req.query_parameters.w);
|
const w = parseInt(req.query_parameters.w);
|
||||||
const h = parseInt(req.query_parameters.h);
|
const h = parseInt(req.query_parameters.h);
|
||||||
const format = req.query_parameters.f;
|
const fit = req.query_parameters.fit;
|
||||||
let force = typeof req.query_parameters.force === "string";
|
let force = typeof req.query_parameters.force === "string";
|
||||||
|
|
||||||
let rpath = decodeURIComponent(req.params._);
|
let rpath = decodeURIComponent(req.params._);
|
||||||
|
|
@ -49,7 +49,9 @@ export const _ = {
|
||||||
return new Response(original);
|
return new Response(original);
|
||||||
}
|
}
|
||||||
|
|
||||||
let path = `${w ? `w-${w}` : ""}${h ? `h-${h}` : ``}`;
|
let path = `${w ? `w-${w}` : ""}${h ? `h-${h}` : ``}${
|
||||||
|
fit ? `-${fit}` : ""
|
||||||
|
}`;
|
||||||
let file_name = dir(
|
let file_name = dir(
|
||||||
`${g.datadir}/files/upload/thumb/${path}/${rpath}.webp`
|
`${g.datadir}/files/upload/thumb/${path}/${rpath}.webp`
|
||||||
);
|
);
|
||||||
|
|
@ -61,12 +63,12 @@ export const _ = {
|
||||||
|
|
||||||
if (force) {
|
if (force) {
|
||||||
const img = sharp(await original.arrayBuffer());
|
const img = sharp(await original.arrayBuffer());
|
||||||
const arg: any = { fit: "inside" };
|
const arg: any = { fit: fit || "inside" };
|
||||||
if (w) {
|
if (w) {
|
||||||
arg.width = w;
|
arg.width = w;
|
||||||
}
|
}
|
||||||
if (h) {
|
if (h) {
|
||||||
arg.width = h;
|
arg.height = h;
|
||||||
}
|
}
|
||||||
let out = img.resize(arg).webp({ quality: 75 });
|
let out = img.resize(arg).webp({ quality: 75 });
|
||||||
out = out.webp();
|
out = out.webp();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue