do not extract face on every request, store face only

This commit is contained in:
jomo
2014-10-19 23:28:21 +02:00
parent 48d33eae25
commit 81c51cdbbe
3 changed files with 41 additions and 23 deletions

View File

@@ -7,27 +7,22 @@ var valid_uuid = /^[0-9a-f]{32}$/;
/* GET home page. */
router.get('/:uuid/:size?', function(req, res) {
//res.render('index', { title: 'Express' });
//res.send("uuid is set to " + req.param("uuid"));
//console.log(req.param('size'))
var uuid = req.param('uuid');
var size = req.param('size') || 180;
console.log(uuid);
if (valid_uuid.test(uuid)) {
var filename = 'skins/' + uuid + ".png";
if (fs.existsSync(filename)) {
skins.extract_face(filename, size, function() {
skins.extract_face(filename, size, function(data) {
res.writeHead(200, {'Content-Type': 'image/png'});
res.end(data);
});
var filename = uuid + ".png";
if (fs.existsSync("skins/" + filename)) {
skins.resize_img(filename, size, function(data) {
res.writeHead(200, {'Content-Type': 'image/png'});
res.end(data);
});
} else {
skins.get_profile(uuid, function(profile) {
var skinurl = skins.skin_url(profile);
if (skinurl) {
skins.skin_file(skinurl, filename, function() {
skins.extract_face(filename, size, function(data) {
skins.resize_img(filename, size, function(data) {
res.writeHead(200, {'Content-Type': 'image/png'});
res.end(data);
});