forked from mtusi2026/mtusi2026lab4
lab4: компенсация без потери объекта при потере ответа COMMIT, полный декод изображений (sharp) в proxy и direct complete
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
/** Keeps every segment through the SOS header and drops the scan data. */
|
||||
export function jpegWithoutScanData(jpeg: Buffer): Buffer {
|
||||
let offset = 2;
|
||||
for (;;) {
|
||||
const marker = jpeg[offset + 1];
|
||||
offset += 2 + jpeg.readUInt16BE(offset + 2);
|
||||
if (marker === 0xda) break;
|
||||
}
|
||||
return Buffer.concat([jpeg.subarray(0, offset), Buffer.from([0xff, 0xd9])]);
|
||||
}
|
||||
@@ -93,3 +93,14 @@ export function noisePng(size: number): Buffer {
|
||||
return padPngTo(png, size);
|
||||
}
|
||||
}
|
||||
|
||||
/** Valid signature, IHDR, CRCs and IEND around a zlib stream of random bytes. */
|
||||
export function pngWithGarbageIdat(): Buffer {
|
||||
return buildPng({
|
||||
width: 320,
|
||||
height: 200,
|
||||
colorType: 2,
|
||||
bitDepth: 8,
|
||||
idat: randomBytes(5000),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user