forked from mtusi2026/mtusi2026lab4
11 lines
359 B
TypeScript
11 lines
359 B
TypeScript
/** 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])]);
|
|
}
|