sylvaingi / meteor-imagemagick

MIT License
23 stars 9 forks source link

Unhandled 'error' event on Meteor 0.8.2 #4

Closed stefanocudini closed 10 years ago

stefanocudini commented 10 years ago

I'm using this code for resize an image:


Meteor.methods({

    uploadAvatar: function(blob) {

        if(!this.userId) return null;

        var fs = Npm.require('fs'),
            path = Meteor.settings.dirs.avatars,
            username = Meteor.user().username,
            filename = username +'_'+ (new Date()).getTime();

        console.log('uploadAvatar: wrinting...', filename);
        fs.writeFileSync(path + filename+'.big.jpg', blob, 'binary');

        console.log('uploadAvatar: resizing...');
        Imagemagick.crop({
            srcPath: path + filename+'.big.jpg',
            dstPath: path + filename+'.jpg',
            width: 160,
            height: 160,
            quality: 0.8
        });

        console.log('uploadAvatar: resized');
        Meteor.users.update(this.userId, {
                $set: {
                    avatar: filename+'.jpg'
                }
            });
    }
});

this cause error:

uploadAvatar: wrinting... stef_1405792951
uploadAvatar: resizing...
events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:998:11)
    at Process.ChildProcess._handle.onexit (child_process.js:789:34)
=> Exited with code: 8
stefanocudini commented 10 years ago

the problem is cause from missing dpkg package: imagemagick

aptitude install imagemagick
stefanocudini commented 10 years ago

@sylvaingi I think that this dependency should be specified in the Readme! ^ _ ^

gauravchl commented 10 years ago

Same error, but on windows 7, meteor 0.8.2 Any solution?