Utils renamed

This commit is contained in:
ful1e5 2021-01-26 12:56:33 +05:30
parent 9fff98b5f6
commit 2213fa761a
3 changed files with 2 additions and 37 deletions

View file

@ -1,19 +0,0 @@
import { PNG } from "pngjs";
import pixelmatch from "pixelmatch";
interface MatchImagesArgs {
img1Buff: Buffer;
img2Buff: Buffer;
}
export const matchImages = ({ img1Buff, img2Buff }: MatchImagesArgs) => {
const img1 = PNG.sync.read(img1Buff);
const img2 = PNG.sync.read(img2Buff);
const { width, height } = img1;
const diff = new PNG({ width, height });
return pixelmatch(img1.data, img2.data, diff.data, width, height, {
threshold: 0.1,
});
};

View file

@ -1,16 +0,0 @@
import fs from "fs";
import path from "path";
import { bitmapsDir } from "../config";
export interface Frames {
[fileName: string]: {
buffer: Buffer;
};
}
export const saveFrames = (frames: Frames) => {
for (let [fileName, { buffer }] of Object.entries(frames)) {
const out_path = path.resolve(bitmapsDir, fileName);
fs.writeFileSync(out_path, buffer, { encoding: "binary" });
}
};

View file

@ -15,5 +15,5 @@ export const template = `
</html>
`;
export const htmlTemplate = (svg: string) =>
template.replace("<svginjection>", svg);
export const toHTML = (svgData: string): string =>
template.replace("<svginjection>", svgData);