mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-22 07:51:17 +01:00
Fix spacing
This commit is contained in:
parent
9de3012702
commit
3fe6be935b
98
skins.js
98
skins.js
@ -9,56 +9,56 @@ var lwip = require('lwip');
|
|||||||
* https://github.com/jomo/Crafatar
|
* https://github.com/jomo/Crafatar
|
||||||
*/
|
*/
|
||||||
module.exports = {
|
module.exports = {
|
||||||
get_profile: function(uuid, callback) {
|
get_profile: function(uuid, callback) {
|
||||||
https.get("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid, function(res) {
|
https.get("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid, function(res) {
|
||||||
if (res.statusCode == "204") {
|
if (res.statusCode == "204") {
|
||||||
callback(null);
|
callback(null);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
res.on('data', function(d) {
|
res.on('data', function(d) {
|
||||||
var profile = JSON.parse(d);
|
var profile = JSON.parse(d);
|
||||||
if (profile.error) callback(null);
|
if (profile.error) callback(null);
|
||||||
callback(profile);
|
callback(profile);
|
||||||
});
|
});
|
||||||
|
|
||||||
}).on('error', function(e) {
|
}).on('error', function(e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
skin_url: function(profile) {
|
skin_url: function(profile) {
|
||||||
var url = null;
|
var url = null;
|
||||||
if (profile && profile.properties) {
|
if (profile && profile.properties) {
|
||||||
profile.properties.forEach(function(prop) {
|
profile.properties.forEach(function(prop) {
|
||||||
if (prop.name == 'textures') {
|
if (prop.name == 'textures') {
|
||||||
var json = Buffer(prop.value, 'base64').toString();
|
var json = Buffer(prop.value, 'base64').toString();
|
||||||
var props = JSON.parse(json);
|
var props = JSON.parse(json);
|
||||||
url = props.textures.SKIN.url;
|
url = props.textures.SKIN.url;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
},
|
},
|
||||||
|
|
||||||
skin_file: function(url, filename, callback) {
|
skin_file: function(url, filename, callback) {
|
||||||
var file = fs.createWriteStream(filename);
|
var file = fs.createWriteStream(filename);
|
||||||
http.get(url, function(res) {
|
http.get(url, function(res) {
|
||||||
res.on('data', function(data) {
|
res.on('data', function(data) {
|
||||||
file.write(data);
|
file.write(data);
|
||||||
}).on('end', function() {
|
}).on('end', function() {
|
||||||
file.end();
|
file.end();
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
extract_face: function(infile, size, callback) {
|
extract_face: function(infile, size, callback) {
|
||||||
lwip.open(infile, function(err, image){
|
lwip.open(infile, function(err, image){
|
||||||
image.batch()
|
image.batch()
|
||||||
.crop(8,8,15,15)
|
.crop(8,8,15,15)
|
||||||
.resize(size, size, "nearest-neighbor")
|
.resize(size, size, "nearest-neighbor")
|
||||||
.toBuffer('png', function(err, buffer){
|
.toBuffer('png', function(err, buffer){
|
||||||
callback(buffer);
|
callback(buffer);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Loading…
x
Reference in New Issue
Block a user