lib/image/imagecrunch.js
function(callback) {
          if (!context.copyOriginal) {
            return callback(null);
          }
          var suffix = 'original.' + context.extension;
          var tempFile = context.tempFolder + '/' + suffix;
          if (context.extension !== 'jpg') {
            // Don't forget to tell the caller that we did the work,
            // even if it was just a copy
            context.adjustedOriginal = tempFile;
            return copyFile(context.workingPath, tempFile, callback);
          }

          var args = [ context.workingPath ];
          if (context.crop) {
            args.push('-crop');
            args.push(context.crop.left);
            args.push(context.crop.top);
            args.push(context.crop.width);
            args.push(context.crop.height);
          }
          args.push('-write');
          args.push(tempFile);
          context.adjustedOriginal = tempFile;

          var proc = childProcess.spawn('imagecrunch', args);
          proc.on('close', function(code) {
            if (code !== 0) {
              return callback(code);
            }
            return callback(null);
          });
        }
function(callback) {
          if (!context.copyOriginal) {
            return callback(null);
          }
          var suffix = 'original.' + context.extension;
          var tempFile = context.tempFolder + '/' + suffix;
          if (context.extension !== 'jpg') {
            // Don't forget to tell the caller that we did the work,
            // even if it was just a copy
            context.adjustedOriginal = tempFile;
            return copyFile(context.workingPath, tempFile, callback);
          }

          var args = [ context.workingPath ];
          if (context.crop) {
            args.push('-crop');
            args.push(context.crop.left);
            args.push(context.crop.top);
            args.push(context.crop.width);
            args.push(context.crop.height);
          }
          args.push('-write');
          args.push(tempFile);
          context.adjustedOriginal = tempFile;

          var proc = childProcess.spawn('imagecrunch', args);
          proc.on('close', function(code) {
            if (code !== 0) {
              return callback(code);
            }
            return callback(null);
          });
        }
function ( callback ) { if ( ! context . copyOriginal ) { return callback ( null ) ; } var suffix = 'original.' + context . extension ; var tempFile = context . tempFolder + '/' + suffix ; if ( context . extension !== 'jpg' ) { // Don't forget to tell the caller that we did the work, // even if it was just a copy context . adjustedOriginal = tempFile ; return copyFile ( context . workingPath , tempFile , callback ) ; } var args = [ context . workingPath ] ; if ( context . crop ) { args . push ( '-crop' ) ; args . push ( context . crop . left ) ; args . push ( context . crop . top ) ; args . push ( context . crop . width ) ; args . push ( context . crop . height ) ; } args . push ( '-write' ) ; args . push ( tempFile ) ; context . adjustedOriginal = tempFile ; var proc = childProcess . spawn ( 'imagecrunch' , args ) ; proc . on ( 'close' , function ( code ) { if ( code !== 0 ) { return callback ( code ) ; } return callback ( null ) ; } ) ; }
Autorotated "original" copied in if desired
Autorotated original copied in if desired