sharp by wasm
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { mkdtempSync, rmSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import sharp from 'sharp';
|
||||
import { optimizeImage } from 'wasm-image-optimization';
|
||||
import LibDashStore from '../src/index.js';
|
||||
import { BetterSqlite3Provider } from '../src/providers/sqlite3/index.js';
|
||||
|
||||
@@ -79,11 +79,9 @@ export async function createCustomer(store, tenant, name = 'Customer') {
|
||||
|
||||
/** Generates a small solid-color PNG buffer for image tests. */
|
||||
export async function makePng({ width = 64, height = 48, r = 200, g = 30, b = 60 } = {}) {
|
||||
return sharp({
|
||||
create: { width, height, channels: 3, background: { r, g, b } },
|
||||
})
|
||||
.png()
|
||||
.toBuffer();
|
||||
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}"><rect width="${width}" height="${height}" fill="rgb(${r},${g},${b})"/></svg>`;
|
||||
const res = await optimizeImage({ image: svg, format: 'png' });
|
||||
return Buffer.from(res.data);
|
||||
}
|
||||
|
||||
export const isoNow = () => new Date().toISOString();
|
||||
|
||||
Reference in New Issue
Block a user