mirror of https://gitgud.io/fatchan/gm
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
972 B
43 lines
972 B
var fs = require("fs");
|
|
|
|
module.exports = function (proto) {
|
|
|
|
proto.avatar = function avatar (name, callback) {
|
|
var self = this;
|
|
|
|
self.size(function (err, size) {
|
|
if (err) {
|
|
return callback.apply(self, arguments);
|
|
}
|
|
|
|
self.original = self.source;
|
|
self.source = '';
|
|
|
|
|
|
self
|
|
.in("-size", size.width + "x" + size.height)
|
|
.in("xc:#ffffff00")
|
|
.drawCircle(size.width / 2, size.height / 2, size.width / 6, size.height / 6)
|
|
.write('mask.png', function(err)
|
|
{
|
|
if (err) {
|
|
return callback.apply(self, arguments);
|
|
}
|
|
|
|
self
|
|
.subCommand("composite")
|
|
.in('-compose', 'In', self.original, 'mask.png')
|
|
.write(name, function(err)
|
|
{
|
|
fs.unlink("mask.png");
|
|
if (err) {
|
|
return callback.apply(self, arguments);
|
|
}
|
|
callback.apply(self, arguments);
|
|
});
|
|
});
|
|
});
|
|
|
|
return self;
|
|
};
|
|
};
|
|
|