Browse files

replace imagemagick with graphicsmagick

  • Loading branch information...
1 parent c8901a7 commit dfa7cc185c3fc406fb2400af463930cd904ce6c3 @madhums committed Aug 10, 2012
Showing with 15 additions and 24 deletions.
  1. +15 −24 lib/imager.js
View
39 lib/imager.js
@@ -1,4 +1,4 @@
-var im = require('imagemagick')
+var gm = require('gm').subClass({ imageMagick: true })
, fs = require('fs')
, path = require('path')
, mime = require('mime')
@@ -66,7 +66,6 @@ Imager.prototype.startUpload = function (file, filename, variant, iteratorCallba
var processFiles = function (cb) {
self.resizeFile(file, { name: name, size: variants.resize[name] }, filename, cb)
}
-
asyncArr.push(processFiles)
})
}
@@ -76,7 +75,6 @@ Imager.prototype.startUpload = function (file, filename, variant, iteratorCallba
var processFiles = function (cb) {
self.cropFile(file, { name: name, size: variants.crop[name] }, filename, cb)
}
-
asyncArr.push(processFiles)
})
}
@@ -97,16 +95,13 @@ Imager.prototype.resizeFile = function (file, preset, fname, cb) {
var remoteFile = preset.name + '_' + filename
, dest = '/tmp/' + remoteFile
- var options = {
- srcPath: file['path']
- , dstPath: dest
- , width: preset.size.split('x')[0]
- }
-
- im.resize(options, function(err, stdout, stderr) {
- if (err) return cb(err)
- self['pushTo' + self.storage](dest, remoteFile, filename, file['type'], cb)
- })
+ gm(file['path'])
+ .resize(preset.size.split('x')[0], preset.size.split('x')[1])
+ .write(dest, function(err) {
+ if (err) return cb(err)
+ self['pushTo' + self.storage](dest, remoteFile, filename, file['type'], cb)
+ }
+ )
}
@@ -119,17 +114,13 @@ Imager.prototype.cropFile = function (file, preset, fname, cb) {
var remoteFile = preset.name + '_' + filename
, dest = '/tmp/' + remoteFile
- var options = {
- srcPath: file['path']
- , dstPath: dest
- , width: preset.size.split('x')[0]
- , height: preset.size.split('x')[1]
- }
-
- im.crop(options, function(err, stdout, stderr){
- if (err) return cb(err)
- self['pushTo' + self.storage](dest, remoteFile, filename, file['type'], cb)
- })
+ gm(file['path'])
+ .crop(preset.size.split('x')[0], preset.size.split('x')[1])
+ .write(dest, function(err) {
+ if (err) return cb(err)
+ self['pushTo' + self.storage](dest, remoteFile, filename, file['type'], cb)
+ }
+ )
}

0 comments on commit dfa7cc1

Please sign in to comment.