function resizeAndCompress(source, target, width, height) {
  sharp(source)
    .resize(width, height)
    .toBuffer()
    .then((data) => {
      tinify.fromBuffer(data).toFile(target, function(error) {
        if (error !== null) {
          throw error;
        } else {
          console.log(`Successfully resized and compressed ${source} to ${target}!`);
        }
      });
    })
    .catch((error) => {
      console.log(`Error resizing and compressing ${source} to ${target}:`, error);
    });
}
/**
 * Resizes and compresses a source image, saving it at the target file path.
 *
 * @param {string} source Full file path to source image.
 * @param {string} target Full file path to the target image.
 * @param {number} width Width of the target image.
 * @param {number} height Height of the target image.
 */
Resizes and compresses a source image, saving it at the target file path.
@param {string} source Full file path to source image.
@param {string} target Full file path to the target image.
@param {number} width Width of the target image.
@param {number} height Height of the target image.
Resizes and compresses a source image saving it at the target file path . @param { string } source Full file path to source image . @param { string } target Full file path to the target image . @param { number } width Width of the target image . @param { number } height Height of the target image .
function resizeAndCompress(source, target, width, height) {
  sharp(source)
    .resize(width, height)
    .toBuffer()
    .then((data) => {
      tinify.fromBuffer(data).toFile(target, function(error) {
        if (error !== null) {
          throw error;
        } else {
          console.log(`Successfully resized and compressed ${source} to ${target}!`);
        }
      });
    })
    .catch((error) => {
      console.log(`Error resizing and compressing ${source} to ${target}:`, error);
    });
}
function resizeAndCompress ( source , target , width , height ) { sharp ( source ) . resize ( width , height ) . toBuffer ( ) . then ( ( data ) => { tinify . fromBuffer ( data ) . toFile ( target , function ( error ) { if ( error !== null ) { throw error ; } else { console . log ( ` ${ source } ${ target } ` ) ; } } ) ; } ) . catch ( ( error ) => { console . log ( ` ${ source } ${ target } ` , error ) ; } ) ; }
Resizes and compresses a source image, saving it at the target file path.
Resizes and compresses a source image saving it at the target file path .