Skip to content

Instantly share code, notes, and snippets.

@ghostbar
Created June 3, 2012 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ghostbar/2862235 to your computer and use it in GitHub Desktop.
Save ghostbar/2862235 to your computer and use it in GitHub Desktop.
Resize images from a given directory
#!/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