Created
September 30, 2016 21:59
-
-
Save masaeedu/9f1c738fa52c48bd55e770054bcea542 to your computer and use it in GitHub Desktop.
Wherefore monads?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fs.readdir(source, function (err, files) { | |
if (err) { | |
console.log('Error finding files: ' + err) | |
} else { | |
files.forEach(function (filename, fileIndex) { | |
console.log(filename) | |
gm(source + filename).size(function (err, values) { | |
if (err) { | |
console.log('Error identifying file size: ' + err) | |
} else { | |
console.log(filename + ' : ' + values) | |
aspect = (values.width / values.height) | |
widths.forEach(function (width, widthIndex) { | |
height = Math.round(width / aspect) | |
console.log('resizing ' + filename + 'to ' + height + 'x' + height) | |
this.resize(width, height).write(dest + 'w' + width + '_' + filename, function(err) { | |
if (err) console.log('Error writing file: ' + err) | |
}) | |
}.bind(this)) | |
} | |
}) | |
}) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment