I'm having issues when executing the following code:
(function(){
var gm = require('gm');
var Promise = require('es6-promise')
.Promise;
function imgAsPromise(imageUrl){
return new Promise(function(resolve, reject){
gm(imageUrl)
.size(function(err, size) {
if (err) {
reject(err);
}
resolve(size);
});
});
}
var imgPromises = [];
var imgUrls = [
'http://cdn.hiconsumption.com/wp-content/uploads/2014/10/2015-Porsche-911-GTS-4.jpg',
'http://avtomaniya.com/pubsource/photo/10712/118-porsche-911-carrera-4-gts-2015-test-drive-avtomaniya-jpg.jpg',
'http://www.joesdaily.com/wp-content/uploads/2014/03/2015-Porsche-Cayman-GTS-2.jpg'
];
for(url in imgUrls){
imgPromises.push(imgAsPromise(url));
}
Promise.all(imgPromises)
.then(function(sizes){
for(size in sizes){
console.log(size);
}
}).catch(function(error){
console.log("Promise.all error:" + error);
});
})();
The thing is that when running the code it breaks and show me the following error message:
Promise.all error:Error: Command failed: gm identify: Unable to open file (2) [No such file or directory]. gm identify: Request did not return an image.
I verified the images sources and every one exists. The promise should resolve after it gets all images sizes but it doesn't. I would appreciate your help figuring out what could be wrong in this code.
I'm using Node.js 5.3.0 on Windows 10 and GraphicsMagick version 1.3.23 Q16 64 bit.
Thanks in advance for your help.