Update dependencies, change thumbnail generation method
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
FROM denoland/deno:ubuntu-1.45.3
|
FROM denoland/deno:ubuntu-1.45.5
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
|
|||||||
15
deno.json
15
deno.json
@@ -25,16 +25,15 @@
|
|||||||
"./": "./",
|
"./": "./",
|
||||||
"xml": "https://deno.land/x/xml@2.1.3/mod.ts",
|
"xml": "https://deno.land/x/xml@2.1.3/mod.ts",
|
||||||
"mrmime": "https://deno.land/x/mrmime@v2.0.0/mod.ts",
|
"mrmime": "https://deno.land/x/mrmime@v2.0.0/mod.ts",
|
||||||
"imagemagick": "https://deno.land/x/imagemagick_deno@0.0.26/mod.ts",
|
|
||||||
"fresh/": "https://deno.land/x/fresh@1.6.8/",
|
"fresh/": "https://deno.land/x/fresh@1.6.8/",
|
||||||
"$fresh/": "https://deno.land/x/fresh@1.6.8/",
|
"$fresh/": "https://deno.land/x/fresh@1.6.8/",
|
||||||
"preact": "https://esm.sh/preact@10.19.6",
|
"preact": "https://esm.sh/preact@10.23.2",
|
||||||
"preact/": "https://esm.sh/preact@10.19.6/",
|
"preact/": "https://esm.sh/preact@10.23.2/",
|
||||||
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.2",
|
"@preact/signals": "https://esm.sh/*@preact/signals@1.3.0",
|
||||||
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.1",
|
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.8.0",
|
||||||
"tailwindcss": "npm:tailwindcss@3.4.4",
|
"tailwindcss": "npm:tailwindcss@3.4.9",
|
||||||
"tailwindcss/": "npm:/tailwindcss@3.4.4/",
|
"tailwindcss/": "npm:/tailwindcss@3.4.9/",
|
||||||
"tailwindcss/plugin": "npm:/tailwindcss@3.4.4/plugin.js",
|
"tailwindcss/plugin": "npm:/tailwindcss@3.4.9/plugin.js",
|
||||||
"std/": "https://deno.land/std@0.224.0/",
|
"std/": "https://deno.land/std@0.224.0/",
|
||||||
"$std/": "https://deno.land/std@0.224.0/"
|
"$std/": "https://deno.land/std@0.224.0/"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Handlers } from 'fresh/server.ts';
|
import { Handlers } from 'fresh/server.ts';
|
||||||
import { ImageMagick, initialize, MagickGeometry } from 'imagemagick';
|
import { resize } from 'https://deno.land/x/deno_image@0.0.4/mod.ts';
|
||||||
|
|
||||||
import { FreshContextState } from '/lib/types.ts';
|
import { FreshContextState } from '/lib/types.ts';
|
||||||
import { getFile } from '/lib/data/files.ts';
|
import { getFile } from '/lib/data/files.ts';
|
||||||
@@ -53,20 +53,7 @@ export const handler: Handlers<Data, FreshContextState> = {
|
|||||||
return new Response('Bad Request', { status: 400 });
|
return new Response('Bad Request', { status: 400 });
|
||||||
}
|
}
|
||||||
|
|
||||||
await initialize();
|
const resizedImageContents = await resize(fileResult.contents!, { width, height, aspectRatio: true });
|
||||||
|
|
||||||
const sizingData = new MagickGeometry(
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
);
|
|
||||||
sizingData.ignoreAspectRatio = false;
|
|
||||||
|
|
||||||
const resizedImageContents = await new Promise<Uint8Array>((resolve) => {
|
|
||||||
ImageMagick.read(fileResult.contents!, (image) => {
|
|
||||||
image.resize(sizingData);
|
|
||||||
image.write((data) => resolve(data));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return new Response(resizedImageContents, {
|
return new Response(resizedImageContents, {
|
||||||
status: 200,
|
status: 200,
|
||||||
|
|||||||
Reference in New Issue
Block a user