mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-16 02:29:50 +00:00
Add test files for now
This commit is contained in:
21
codecs/visdif/visdif.test.mjs
Normal file
21
codecs/visdif/visdif.test.mjs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import {dirname} from "path";
|
||||||
|
globalThis.__dirname = dirname(import.meta.url);
|
||||||
|
import { createRequire } from 'module';
|
||||||
|
|
||||||
|
globalThis.require = createRequire(import.meta.url);
|
||||||
|
import visdif from './visdif.js';
|
||||||
|
|
||||||
|
const {VisDiff} = await visdif({
|
||||||
|
locateFile() {
|
||||||
|
return new URL("./visdif.wasm", import.meta.url).pathname;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const comparator = new VisDiff(
|
||||||
|
new Uint8ClampedArray([0, 0, 0, 255]),
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
|
||||||
|
const distance = comparator.distance(new Uint8ClampedArray([1,1,1,255]));
|
||||||
|
console.log({distance});
|
||||||
18
libsquoosh/libsquoosh.test.mjs
Normal file
18
libsquoosh/libsquoosh.test.mjs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { ImagePool } from './build/index.js';
|
||||||
|
|
||||||
|
console.log("Starting");
|
||||||
|
const imagePool = new ImagePool();
|
||||||
|
// const imagePath = '/Users/surma/Downloads/happy_dog.png';
|
||||||
|
const imagePath = './squoosh.png';
|
||||||
|
console.log("INgesting");
|
||||||
|
const image = imagePool.ingestImage(imagePath);
|
||||||
|
console.log("Decoding");
|
||||||
|
await image.decoded;
|
||||||
|
const encodeOptions = {
|
||||||
|
mozjpeg: 'auto',
|
||||||
|
};
|
||||||
|
console.log("Encoding");
|
||||||
|
await image.encode(encodeOptions);
|
||||||
|
console.log("Closing");
|
||||||
|
await imagePool.close();
|
||||||
|
console.log("Done");
|
||||||
BIN
libsquoosh/squoosh.png
Normal file
BIN
libsquoosh/squoosh.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
Reference in New Issue
Block a user