make image loading work even in compiled version (?)
This commit is contained in:
parent
a656d37d8c
commit
1ba396bc7c
1 changed files with 14 additions and 12 deletions
26
cli/main.ts
26
cli/main.ts
|
@ -1,10 +1,6 @@
|
|||
import { parse } from "https://deno.land/std@0.106.0/flags/mod.ts";
|
||||
import { createCanvas, loadImage } from "https://deno.land/x/canvas/mod.ts";
|
||||
import {
|
||||
CollageModes,
|
||||
CollageModeType,
|
||||
collageModeType,
|
||||
} from "../src/common/collages.ts";
|
||||
import { createCanvas, init } from "https://deno.land/x/canvas/mod.ts";
|
||||
import { CollageModeType, collageModeType } from "../src/common/collages.ts";
|
||||
import DenoCollageModes, {
|
||||
CastCanvasRenderingContext,
|
||||
ProxyImage,
|
||||
|
@ -12,22 +8,28 @@ import DenoCollageModes, {
|
|||
import { CollageConfig } from "../src/common/types.ts";
|
||||
import { choice, shuffle } from "../src/common/utils.ts";
|
||||
|
||||
const canvasKit = await init();
|
||||
|
||||
const args = parse(Deno.args, {
|
||||
alias: {
|
||||
"w": "width",
|
||||
"h": "height",
|
||||
"o": "output",
|
||||
"m": "mode",
|
||||
},
|
||||
});
|
||||
|
||||
const images: ProxyImage[] =
|
||||
(await Promise.all(
|
||||
args["_"].map((imageURL) => loadImage(imageURL.toString())),
|
||||
)).map((image) => new ProxyImage(image));
|
||||
|
||||
if (images.length < 2) {
|
||||
if (args["_"].length < 2) {
|
||||
console.error("kollagen needs at least 2 images to work.");
|
||||
Deno.exit(1);
|
||||
}
|
||||
|
||||
const images: ProxyImage[] = (await Promise.all(
|
||||
args["_"].map(async (imageURL) =>
|
||||
canvasKit.MakeImageFromEncoded(await Deno.readFile(imageURL.toString()))
|
||||
),
|
||||
)).map((image) => new ProxyImage(image!));
|
||||
|
||||
const modes = new DenoCollageModes();
|
||||
|
||||
const modeKey: CollageModeType = args["mode"] || choice(collageModeType);
|
||||
|
|
Loading…
Reference in a new issue