Add offenders to imageOptimization

This commit is contained in:
Gaël Métais
2015-06-01 16:52:50 +02:00
parent 1606cbab18
commit 9ccca3b33b
9 changed files with 85 additions and 47 deletions
+3 -1
View File
@@ -149,10 +149,12 @@ var ImageOptimizer = function() {
return deferred.promise;
}
// The gain is estimated of enough value if it's over 2KB or over 20%,
// but it's ignored if is below 100 bytes
function gainIsEnough(oldWeight, newWeight) {
var gain = oldWeight - newWeight;
var ratio = gain / oldWeight;
return (gain > 2048 || ratio > 0.2);
return (gain > 2048 || (ratio > 0.2 && gain > 100));
}
function isJpeg(entry) {