nl_tokens: Create thumbnails . For each provided images generate a low - res jpg thumbnail . Even for gif . We don t check if the format of the images is valid since the check is already done when constructing the images object .
pl_tokens: async function createThumbnails ( target , images ) { for ( const x of images ) { const imagePath = path . join ( target , x ) const thumbPath = <mask> . join ( target , ` ${ x } ` ) try { // Background and flatten are for transparent PNGs/Gifs. // We force a white background here. await sharp ( imagePath ) . resize ( 450 ) . background ( { r : 255 , g : 255 , b : 255 , alpha : 1 } ) . flatten ( ) . jpeg ( ) . toFile ( thumbPath ) } catch ( e ) { const msg = chalk . dim ( ` ${ e . message } ` ) console . warn ( ` ${ chalk . bold ( x ) } ${ msg } ` ) } } }