Browse Source

skip helm for images without alpha channel

hotfix for #117
jomo 10 years ago
parent
commit
f36cfa7898
2 changed files with 17 additions and 12 deletions
  1. 1 1
      lib/public/stylesheets/style.css
  2. 16 11
      lib/skins.js

+ 1 - 1
lib/public/stylesheets/style.css

@@ -245,7 +245,7 @@ img.preload {
 .avatar.jeb:hover {background-image: url("/avatars/853c80ef3c3749fdaa49938b674adae6?size=64&helm")}
 
 .avatar.notch {background-image: url("/avatars/069a79f444e94726a5befca90e38aaf5?size=64")}
-/* Notch fucked up his helm */
+.avatar.notch:hover {background-image: url("/avatars/069a79f444e94726a5befca90e38aaf5?size=64&helm")}
 
 .avatar.dinnerbone {background-image: url("/avatars/61699b2ed3274a019f1e0ea8c3f06bc6?size=64")}
 .avatar.dinnerbone:hover {background-image: url("/avatars/61699b2ed3274a019f1e0ea8c3f06bc6?size=64&helm")}

+ 16 - 11
lib/skins.js

@@ -48,17 +48,22 @@ exp.extract_helm = function(rid, facefile, buffer, outname, callback) {
                   if (img_err) {
                     callback(img_err);
                   } else {
-                    face_helm_img.toBuffer("png", {compression: "none"}, function(buf_err2, face_helm_buffer) {
-                      // FIXME: buf_err2 is not handled
-                      if (face_helm_buffer.toString() !== face_buffer.toString()) {
-                        face_helm_img.writeFile(outname, function(write_err) {
-                          callback(write_err);
-                        });
-                      } else {
-                        logging.log(rid, "helm img == face img, not storing!");
-                        callback(null);
-                      }
-                    });
+                    if (!skin_img.__trans) {
+                      logging.log(rid, "Skin is not transparent, skipping helm!");
+                      callback(null);
+                    } else {
+                      face_helm_img.toBuffer("png", {compression: "none"}, function(buf_err2, face_helm_buffer) {
+                        // FIXME: buf_err2 is not handled
+                        if (face_helm_buffer.toString() !== face_buffer.toString()) {
+                          face_helm_img.writeFile(outname, function(write_err) {
+                            callback(write_err);
+                          });
+                        } else {
+                          logging.log(rid, "helm img == face img, not storing!");
+                          callback(null);
+                        }
+                      });
+                    }
                   }
                 });
               }