     ws.once 'close', ->
       fs.fsync fd, ->
         try
-          onEnd tmpFile, cascade, callback
+          callback null, tmpFile
         catch error
           callback error
           tmpFile.unlink()
   rs.pipe ws
 
-onEnd = (tmpFile, cascade, callback) ->
+runScdDetect = (tmpFile, cascade, callback) ->
   bin = path.join __dirname, '../build/Release/scddetect'
   exec "#{bin} #{tmpFile.path} #{cascade}", (err, stdout, stderr) ->
     if err

    out: 'out'
    forwardGroups: true
    async: true
  , (payload, groups, out, callback) ->
    if not c.params.cascade
      cascade = path.join __dirname, '../cascades/face.sqlite3'
    else
      cascade = c.params.cascade
    compute payload, cascade, (err, val) ->
      return callback err if err
      out.send val
      do callback
  c

# @runtime noflo-nodejs
# @name SCDDetect

writeCanvasTempFile = (canvas, callback) ->
  tmpFile = new temporary.File

  rs = canvas.pngStream()
