sharp by wasm
This commit is contained in:
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict';
|
||||
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';
|
||||
|
||||
@@ -42,16 +42,9 @@ async function run() {
|
||||
assert.ok(val.id > 0);
|
||||
|
||||
// Create a 100x100 test image
|
||||
const imageBuffer = await sharp({
|
||||
create: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
channels: 4,
|
||||
background: { r: 25, g: 25, b: 112, alpha: 1 },
|
||||
},
|
||||
})
|
||||
.avif()
|
||||
.toBuffer();
|
||||
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><rect width="100" height="100" fill="rgb(25,25,112)"/></svg>`;
|
||||
const encoded = await optimizeImage({ image: svg, format: 'avif' });
|
||||
const imageBuffer = Buffer.from(encoded.data);
|
||||
|
||||
console.log('1. Adding image to attribute value...');
|
||||
const addResult = await store.attributevalue.addImage(googleAuthId, val.id, imageBuffer);
|
||||
|
||||
Reference in New Issue
Block a user