mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-14 01:37:26 +00:00
Keep planarized reference image around across runs
This commit is contained in:
16
cli/index.js
16
cli/index.js
@@ -24,10 +24,16 @@ async function optimize(bitmapIn, encode, decode) {
|
||||
let bitmapOut;
|
||||
let binaryOut;
|
||||
|
||||
const { visdif } = await visdifModule();
|
||||
const { VisDiff } = await visdifModule();
|
||||
const comparator = new VisDiff(
|
||||
bitmapIn.data,
|
||||
bitmapIn.width,
|
||||
bitmapIn.height
|
||||
);
|
||||
do {
|
||||
binaryOut = await encode(bitmapIn, quality);
|
||||
bitmapOut = await decode(binaryOut);
|
||||
butteraugliDistance = comparator.distance(bitmapOut.data);
|
||||
console.log({
|
||||
butteraugliDistance,
|
||||
quality,
|
||||
@@ -35,12 +41,6 @@ async function optimize(bitmapIn, encode, decode) {
|
||||
binaryOut,
|
||||
bitmapOut
|
||||
});
|
||||
butteraugliDistance = visdif(
|
||||
bitmapIn.data,
|
||||
bitmapOut.data,
|
||||
bitmapIn.width,
|
||||
bitmapIn.height
|
||||
);
|
||||
if (butteraugliDistance > butteraugliGoal) {
|
||||
quality += inc;
|
||||
} else {
|
||||
@@ -53,6 +53,8 @@ async function optimize(bitmapIn, encode, decode) {
|
||||
attempts < maxRounds
|
||||
);
|
||||
|
||||
comparator.delete();
|
||||
|
||||
return {
|
||||
bitmap: bitmapOut,
|
||||
binary: binaryOut,
|
||||
|
||||
Reference in New Issue
Block a user