Skip to content

Commit e5e2363

Browse files
committed
Moved from BGR to RGB
1 parent de30e93 commit e5e2363

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

src/hashing.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,14 @@ export async function computeHashesFromStream(
5454
}
5555

5656
if (resize) {
57-
const resizer = sharp()
58-
.resize(448, 448, { kernel: 'linear' })
59-
.raw({ depth: 'char' });
60-
stream.pipe(resizer);
61-
const rgbData = await resizer.toBuffer();
62-
// Sharp outputs RGB format, but Athena expects BGR - swap R and B channels
63-
data = Buffer.alloc(rgbData.length);
64-
for (let i = 0; i < rgbData.length; i += 3) {
65-
data[i] = rgbData[i + 2]; // B <- R
66-
data[i + 1] = rgbData[i + 1]; // G <- G
67-
data[i + 2] = rgbData[i]; // R <- B
68-
}
57+
const rawBuffer = await buffer(stream);
58+
59+
data = await sharp(rawBuffer)
60+
.resize(448, 448)
61+
.removeAlpha()
62+
.raw({ depth: 'uchar' })
63+
.toBuffer();
64+
6965
imageFormat = ImageFormat.IMAGE_FORMAT_RAW_UINT8_BGR;
7066
} else {
7167
data = await buffer(stream);

0 commit comments

Comments
 (0)