Tidy up image resizing example

This commit is contained in:
SteveSandersonMS
2016-06-07 17:46:42 +01:00
parent e58a4e4015
commit 7af64a8944
2 changed files with 18 additions and 15 deletions

View File

@@ -1,7 +1,8 @@
var sharp = require('sharp');
module.exports = function(result, physicalPath, mimeType, maxWidth, maxHeight) {
// Invoke the 'sharp' NPM module, and have it pipe the resulting image data back to .NET
sharp(physicalPath)
.resize(maxWidth > 0 ? maxWidth : null, maxHeight > 0 ? maxHeight : null)
.resize(maxWidth || null, maxHeight || null)
.pipe(result.stream);
}