File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments