File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -6,16 +6,18 @@ function run(cfg) {
66 const lqip = ( cfg && parseInt ( cfg ) ) ?? 16
77 if ( lqip ) {
88 const { image } = metadatas . find ( ( i ) => i . src === pic . img . src )
9- let data
109 if ( lqip > 1 ) {
11- const buf = await image . resize ( { width : lqip } ) . toFormat ( 'webp' , { quality : 20 } ) . toBuffer ( )
12- data = buf . toString ( 'base64' )
10+ const buf = await image
11+ . clone ( )
12+ . resize ( { width : lqip } )
13+ . toFormat ( 'webp' , { quality : 20 } )
14+ . toBuffer ( )
15+ pic . img . lqip = buf . toString ( 'base64' )
1316 } else {
1417 const { dominant } = await image . stats ( )
1518 const { r, g, b } = dominant
16- data = '#' + ( ( 1 << 24 ) | ( r << 16 ) | ( g << 8 ) | b ) . toString ( 16 ) . slice ( 1 )
19+ pic . img . lqip = '#' + ( ( 1 << 24 ) | ( r << 16 ) | ( g << 8 ) | b ) . toString ( 16 ) . slice ( 1 )
1720 }
18- pic . img . lqip = data
1921 }
2022 return pic
2123 }
You can’t perform that action at this time.
0 commit comments