derhuerst / gulp-scale-images

Gulp plugin to resize each image into multiple smaller variants.
https://github.com/derhuerst/gulp-scale-images#gulp-scale-images
ISC License
13 stars 5 forks source link

Small issue in README examples #6

Closed woodpig07 closed 6 years ago

woodpig07 commented 6 years ago

First of all, I really like your work for this plugin as I do prefer sharp over gm.

It looks there were two minor mistakes in your README examples that prevent the code from working as expected: https://github.com/derhuerst/gulp-scale-images#definining-scale-instructions-based-on-metadata

const computeScaleInstructions = (file, _, cb) => {
    readMetadata(file.path, (err, meta) => {
        if (err) return cb(err)
        file.scale = {
            maxWidth: Math.floor(meta.width / 2),
            maxHeight: Math.floor(meta.height / 2)
        }
        cb(null, scale)
    })
}

The cb(null, scale) should be cb(null, file)

https://github.com/derhuerst/gulp-scale-images#custom-output-file-names

const computeFileName = (output, scale, cb) => {
    const fileName = [
        path.basename(output.path, output.extname), // strip extension
        scale.maxWidth + 'w',
        scale.format || output.extname
    ].join('.')
}

It's missing cb(null, fileName) at the last line before the closing bracket.

derhuerst commented 6 years ago

Good catch!