Closed woodpig07 closed 6 years ago
First of all, I really like your work for this plugin as I do prefer sharp over gm.
sharp
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)
cb(null, scale)
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.
cb(null, fileName)
Good catch!
First of all, I really like your work for this plugin as I do prefer
sharp
overgm
.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
The
cb(null, scale)
should becb(null, file)
https://github.com/derhuerst/gulp-scale-images#custom-output-file-names
It's missing
cb(null, fileName)
at the last line before the closing bracket.