Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/screenshots/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
export const MARK_BYTES_PER_PIXEL = 4;
export const MARK_LENGTH = 32;
export const MARK_HEIGHT = 10;
export const MARK_RIGHT_MARGIN = 10;
export const MARK_RIGHT_MARGIN = 25;
31 changes: 17 additions & 14 deletions test/server/crop-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
const expect = require('chai').expect;
const expect = require('chai').expect;

const {
MARK_LENGTH,
MARK_BYTES_PER_PIXEL,
MARK_RIGHT_MARGIN,
} = require('../../lib/screenshots/constants');

const {
getClipInfoByCropDimensions,
Expand All @@ -7,23 +13,20 @@ const {
calculateClipInfo,
} = require('../../lib/screenshots/crop');

const markSeed = [
0, 0, 0, 255,
255, 255, 255, 255,
0, 0, 0, 255,
255, 255, 255, 255,
0, 0, 0, 255,
255, 255, 255, 255,
];
const markSeed = Array(MARK_LENGTH).fill().flatMap((_, i) => i % 2 ? [255, 255, 255, 255] : [0, 0, 0, 255]);

function getPngMock (mark = markSeed) {
const markSeedIndex = 6944952;
const width = 1820;
const height = 954;
const width = 1820;
const height = 954;
const length = width * height * MARK_BYTES_PER_PIXEL;
const markSeedOffset = (MARK_LENGTH + MARK_RIGHT_MARGIN) * MARK_BYTES_PER_PIXEL;
const markSeedIndex = length - markSeedOffset;

let data = '-'.repeat(markSeedIndex);
const dataHeader = Buffer.from('-'.repeat(markSeedIndex));
const dataMark = Buffer.from(mark);
const dataTrailer = Buffer.from('-'.repeat(MARK_RIGHT_MARGIN * MARK_BYTES_PER_PIXEL));

data = Buffer.concat([Buffer.from(data), Buffer.from(mark), Buffer.from(data)]);
const data = Buffer.concat([dataHeader, dataMark, dataTrailer]);

return { width, height, data };
}
Expand Down