lib/generate.js
function generateSizes(entry, inputDirectory, outputDirectory) {
  const imageFileName = path.join(inputDirectory, entry.basename);
  return pify(fs.readFile)(imageFileName).then(imageBuffer => {
    const sharpFile = sharp(imageBuffer);
    return Promise.all(
      entry.sizes.map(size => {
        const sizeSuffix = createSizeSuffix(size.width, size.height);
        const ext = path.extname(entry.basename);
        const extlessBasename = path.basename(entry.basename, ext);
        const outputFilename = path.join(
          outputDirectory,
          `${extlessBasename}-${sizeSuffix}${ext}`
        );
        const transform = sharpFile.resize(size.width, size.height);
        if (size.crop !== undefined) {
          transform.crop(getCropper(size.crop));
        }
        return transform.toFile(outputFilename).then(() => outputFilename);
      })
    );
  });
}
function generateSizes(entry, inputDirectory, outputDirectory) {
  const imageFileName = path.join(inputDirectory, entry.basename);
  return pify(fs.readFile)(imageFileName).then(imageBuffer => {
    const sharpFile = sharp(imageBuffer);
    return Promise.all(
      entry.sizes.map(size => {
        const sizeSuffix = createSizeSuffix(size.width, size.height);
        const ext = path.extname(entry.basename);
        const extlessBasename = path.basename(entry.basename, ext);
        const outputFilename = path.join(
          outputDirectory,
          `${extlessBasename}-${sizeSuffix}${ext}`
        );
        const transform = sharpFile.resize(size.width, size.height);
        if (size.crop !== undefined) {
          transform.crop(getCropper(size.crop));
        }
        return transform.toFile(outputFilename).then(() => outputFilename);
      })
    );
  });
}
function generateSizes ( entry , inputDirectory , outputDirectory ) { const imageFileName = path . join ( inputDirectory , entry . basename ) ; return pify ( fs . readFile ) ( imageFileName ) . then ( imageBuffer => { const sharpFile = sharp ( imageBuffer ) ; return Promise . all ( entry . sizes . map ( size => { const sizeSuffix = createSizeSuffix ( size . width , size . height ) ; const ext = path . extname ( entry . basename ) ; const extlessBasename = path . basename ( entry . basename , ext ) ; const outputFilename = path . join ( outputDirectory , ` ${ extlessBasename } ${ sizeSuffix } ${ ext } ` ) ; const transform = sharpFile . resize ( size . width , size . height ) ; if ( size . crop !== undefined ) { transform . crop ( getCropper ( size . crop ) ) ; } return transform . toFile ( outputFilename ) . then ( ( ) => outputFilename ) ; } ) ) ; } ) ; }
Generate all the size variants of an image.

@param {Object} entry - Entry in the image config.
@param {string} inputDirectory
@param {string} outputDirectory
@return {Promise<Array<string>>} - Resolves with an array of the output filenames.
Generate all the size variants of an image .