diff --git a/packages/core/src/util.ts b/packages/core/src/util.ts new file mode 100644 index 00000000..574b1f60 --- /dev/null +++ b/packages/core/src/util.ts @@ -0,0 +1,16 @@ +import sharp from "sharp"; + +export function loadImageFromDisk(path: string) { + return sharp(path) +} + +export function loadImageFromBuffer(buf: Buffer) { + return sharp(buf) +} + +/** + * This function calculates the cartesian product of two or more array and is straight from stackoverflow ;) + * Should be replaced with something more legible but works for now. + * @internal + */ + export const cartesian = (...a: any[]) => a.reduce((a: any, b: any) => a.flatMap((d: any) => b.map((e: any) => [d, e].flat())))