title: Adding extra parameters to a callback
body: <p>So after reading up I see that I need a closure or to use bind but I am not fully clear on the proper syntax and which I should use.</p>
  
  <p>I am using the imagemagick module from <a href="https://github.com/rsms/node-imagemagick" rel="nofollow">https://github.com/rsms/node-imagemagick</a> and need to pass the filename to the resize callback.</p>
  
  <p>Syntax is:</p>
  
  <pre><code>var filename = 'myfile.jpeg';
  im.resize(options, callback(err, stdout, stderr))
  </code></pre>
  
  <p>Now I want my callback to accept extra parameters such as the filename.</p>
  
  <p>I would like to be able to call another function and have the filename along with the 3 callback parameters (also note that this is in a loop so the filename is from an array - not sure if that matters)</p>
  
  <p>So I have a callback function:</p>
  
  <pre><code>var callback = function(err, stdout, stderr) {
      //how do I access filename?
  }
  </code></pre>
  
  <p>Can I get an explanation of which I should use (closure or bind) and pros/cons and, if a closure, how would I actually write the callback function - I am unclear on how I access err, stdout and stderr in that way.</p>