im.identify
以下では、 beforeを評価しようとしましたconsole.log(toObtain)
がconsole.log(toObtain)
、 after が呼び出されたようim.identify
です。関数が呼び出したい順序で正確に呼び出されるようにするにはどうすればよいですか?
var toObtain; //I'm trying to set the value of this variable to features (inside the callback).
var im = require('imagemagick');
im.identify('kittens.png', function(err, features){
if (err) throw err
//console.log(features);
toObtain = features;
console.log(toObtain); //this prints { format: 'PNG', width: 400, height: 300, depth: 8 }
})
console.log(toObtain); //This function call is evaluated BEFORE im.identify, which is exactly the opposite of what I wanted to do.