Created
June 3, 2012 06:28
-
-
Save ghostbar/2862235 to your computer and use it in GitHub Desktop.
Resize images from a given directory
This file contains 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
#!/usr/bin/env coffee | |
fs = require 'fs' | |
im = require 'imagemagick' | |
_ = require 'underscore' | |
srcdir = __dirname + '/enviar' | |
destdir = __dirname + '/done' | |
log = (message) -> | |
console.log message | |
fs.readdir srcdir, (err, files) => | |
if err | |
log err | |
_.each files, (obj) => | |
opts = | |
srcPath: "#{srcdir}/#{obj}" | |
dstPath: "#{destdir}/#{obj}" | |
height: 1024 | |
im.resize opts, (err, stdout, stderr) -> | |
if err | |
throw err | |
log stderr.trim() | |
log "Resized #{opts.srcPath}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment