mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-14 09:39:15 +00:00
Add test case
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "avif",
|
"name": "avif",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "../build-cpp.sh"
|
"build": "../build-cpp.sh"
|
||||||
}
|
}
|
||||||
|
|||||||
22
codecs/visdif/test.mjs
Normal file
22
codecs/visdif/test.mjs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
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});
|
||||||
Reference in New Issue
Block a user