Compare commits

..
Author SHA1 Message Date
Gaël MétaisandGitHub 773249ca4f Revert "Introduce a new "Old Image Formats" rule" 2023-08-12 04:07:03 +02:00
Gaël MétaisandGitHub 599d02ea0e Merge pull request #387 from YellowLabTools/webp-avif
Introduce a new "Old Image Formats" rule
2023-07-30 22:47:10 +02:00
14 changed files with 223 additions and 194 deletions
+1 -3
View File
@@ -33,11 +33,10 @@ var yellowLabTools = function(url, options) {
// If a screenshot saveFunction was provided in the options
if (options && typeof options.saveScreenshotFn === 'function') {
const screenshotTmpPath = data.params.options.screenshot;
debug('Now optimizing screenshot...');
// TODO: temporarily set all screenshot sizes to 600px, until we find a solution
ScreenshotHandler.findAndOptimizeScreenshot(screenshotTmpPath, 600)
ScreenshotHandler.findAndOptimizeScreenshot(data.params.options.screenshot, 600)
.then(function(screenshotBuffer) {
debug('Screenshot optimized, now saving...');
@@ -51,7 +50,6 @@ var yellowLabTools = function(url, options) {
// Remove uneeded temp screenshot path
delete data.params.options.screenshot;
return ScreenshotHandler.deleteTmpFile(screenshotTmpPath);
})
.catch(function(err) {
+16 -90
View File
@@ -54,7 +54,7 @@ var policies = {
"isBadThreshold": 2000,
"isAbnormalThreshold": 4000,
"hasOffenders": false,
"unit": "ms"
"unit": 'ms'
},
"DOMaccesses": {
"tool": "domAccessAgregator",
@@ -729,101 +729,27 @@ var policies = {
"totalWeight": {
"tool": "redownload",
"label": "Total weight",
"message": "<p>The weight is of course very important if you want the page to load fast. Try to stay under 1.5MB.</p>",
"message": "<p>The weight is of course very important if you want the page to load fast. Try to stay under 1MB, which is already very long to download over a slow connection.</p>",
"isOkThreshold": 1572864,
"isBadThreshold": 3145728,
"isAbnormalThreshold": 5242880,
"hasOffenders": true,
"unit": "bytes"
"unit": 'bytes'
},
"imagesNotOptimized": {
"tool": "phantomas",
"imageOptimization": {
"tool": "redownload",
"label": "Image optimization",
"message": "<p>This metric measures the number of bytes that could be saved by optimizing images.</p><p>Image optimization is generally one of the easiest way to reduce a page weight, and as a result, the page load time. Don't use Photoshop or other image editing tools, they're not very good for optimization. Use specialized tools such as <a href=\"https://kraken.io/\" target=\"_blank\">Kraken.io</a> or the excellent <a href=\"https://imageoptim.com/\" target=\"_blank\">ImageOptim</a> on Mac. For SVG images, you can use <a href=\"https://jakearchibald.github.io/svgomg/\" target=\"_blank\">SVGOMG</a>.</p><p>The tools in use in YellowLabTools are not set to their maximum optimization power, so you might be able to compress even more!</p>",
"isOkThreshold": 2048,
"message": "<p>This metric measures the number of bytes that could be saved by optimizing images.</p><p>Image optimization is generally one of the easiest way to reduce a page weight, and as a result, the page load time. Don't use Photoshop or other image editing tools, they're not very good for optimization. Use specialized tools such as <a href=\"https://kraken.io/\" target=\"_blank\">Kraken.io</a> or the excellent <a href=\"https://imageoptim.com/\" target=\"_blank\">ImageOptim</a> on Mac. For SVG images, you can use <a href=\"https://jakearchibald.github.io/svgomg/\" target=\"_blank\">SVGOMG</a>.</p><p>The tools in use in YellowLabTools are not set to their maximum optimization power (JPEG quality 85), so you might be able to compress even more!</p>",
"isOkThreshold": 20480,
"isBadThreshold": 204800,
"isAbnormalThreshold": 307200,
"hasOffenders": true,
"unit": "bytes",
"valueTransformFn": function(offenders) {
let totalGain = 0;
offenders.forEach((offender) => {
offender.gain = offender.fileSize - offender.newFileSize;
totalGain += offender.gain;
});
return totalGain;
},
"offendersTransformFn": function(offenders) {
return offenders;
}
"unit": 'bytes'
},
"imagesOldFormat": {
"tool": "phantomas",
"label": "Old image formats",
"message": "<p>This metric goes further than \"Image optimization\". Measures the number of bytes that could be saved by converting images to newer and more efficient formats. The best image format is generally AVIF and the second best is WebP.</p><p>Be careful, you need to provide fallback images for old browsers and search engine bots.</p>",
"isOkThreshold": 2048,
"isBadThreshold": 512000,
"isAbnormalThreshold": 819200,
"hasOffenders": true,
"unit": "bytes",
"valueTransformFn": function(offenders) {
let totalGain = 0;
offenders.forEach((offender) => {
offender.gain = offender.fileSize - offender.newFileSize;
totalGain += offender.gain;
});
return totalGain;
},
"offendersTransformFn": function(offenders) {
return offenders;
}
},
"imagesScaledDown": {
"tool": "phantomas",
"imagesTooLarge": {
"tool": "redownload",
"label": "Oversized images",
"message": "<p>This rule compares the number of pixels in a loaded images to the number of physical pixels it is displayed on. Then it estimates the number of KB that could be saved by serving it with the correct dimensions.</p><p>Of course, it is hard to serve perfect images for all screens. For this reason, this rule is quite permissive.</p>",
"isOkThreshold": 2048,
"isBadThreshold": 307200,
"isAbnormalThreshold": 512000,
"hasOffenders": true,
"unit": "bytes",
"valueTransformFn": function(offenders) {
let totalGain = 0;
offenders.forEach((offender) => {
offender.gain = offender.fileSize - offender.newFileSize;
totalGain += offender.gain;
});
return totalGain;
},
"offendersTransformFn": function(offenders) {
return offenders;
}
},
"imagesExcessiveDensity": {
"tool": "phantomas",
"label": "Excessive image density",
"message": "<p>This metric measures the number of bytes that could be saved by going further than just resizing images.<p>Devices with very high pixel density screen (such as 3x or 4x) are programmed to load high density images. This is the normal behavior, however the human eye barely sees the difference over 2x. This metric alerts you if an image density is > 2.2x.</p><p>There is currently no browser functionnality to prevent the issue (for this reason its impact on global score is low). But you can build your own clever solution!</p>",
"isOkThreshold": 102400,
"isBadThreshold": 307200,
"isAbnormalThreshold": 512000,
"hasOffenders": true,
"unit": "bytes",
"valueTransformFn": function(offenders) {
let totalGain = 0;
offenders.forEach((offender) => {
offender.gain = offender.fileSize - offender.newFileSize;
totalGain += offender.gain;
});
return totalGain;
},
"offendersTransformFn": function(offenders) {
return offenders;
}
},
"imagesWithIncorrectSizesParam": {
"tool": "phantomas",
"label": "Incorrect sizes parameter",
"message": "<p>When using an adaptative image with a <i>srcset</i> attribute and <i>w</i> values, it is important to correctly set the <i>sizes</i> attribute. Otherwise, the browser might pick the wrong image in the <i>srcset</i>.</p><p>The <a href=\”https://chrome.google.com/webstore/detail/responsive-image-linter/mnddginionlghpblkimpdalcecpnbjln\" target=\"_blank\">Responsive Image Linter</a> extension for Chrome can help you further.</p>",
"message": "<p>This is the number of images with a width >1200px on mobile, >1800px on tablet, >2400 on desktop, >3200px on HD desktop. Try reducing their size.</p><p>Please ignore if the file is used as a sprite.</p>",
"isOkThreshold": 0,
"isBadThreshold": 5,
"isAbnormalThreshold": 10,
@@ -837,7 +763,7 @@ var policies = {
"isBadThreshold": 204800,
"isAbnormalThreshold": 409600,
"hasOffenders": true,
"unit": "bytes"
"unit": 'bytes'
},
"fileMinification": {
"tool": "redownload",
@@ -847,12 +773,12 @@ var policies = {
"isBadThreshold": 61440,
"isAbnormalThreshold": 122880,
"hasOffenders": true,
"unit": "bytes"
"unit": 'bytes'
},
"totalRequests": {
"tool": "redownload",
"label": "Requests number",
"message": "<p>Each request slows down the page loading, especially on the protocol HTTP/1, but also a little on HTTP/2 or 3.</p><p>There are several technics to reduce their number:<ul><li>Concatenate JS files</li><li>Concatenate CSS files</li><li>Embed or inline small JS or CSS files in the HTML</li><li>Create sprites</li><li>Base64 encode small images in HTML or stylesheets</li><li>Use lazyloading for images</li></ul></p>",
"message": "<p>Each request slows down the page loading, especially on the protocol HTTP/1, but also a little on HTTP/2.</p><p>There are several technics to reduce their number:<ul><li>Concatenate JS files</li><li>Concatenate CSS files</li><li>Embed or inline small JS or CSS files in the HTML</li><li>Create sprites</li><li>Base64 encode small images in HTML or stylesheets</li><li>Use lazyloading for images</li></ul></p>",
"isOkThreshold": 80,
"isBadThreshold": 240,
"isAbnormalThreshold": 320,
@@ -943,7 +869,7 @@ var policies = {
"isOkThreshold": 0,
"isBadThreshold": 102400,
"isAbnormalThreshold": 204800,
"unit": "bytes",
"unit": 'bytes',
"hasOffenders": true,
"offendersTransformFn": function(offenders) {
return offenders;
@@ -969,7 +895,7 @@ var policies = {
"isBadThreshold": 51200,
"isAbnormalThreshold": 122880,
"hasOffenders": true,
"unit": "bytes"
"unit": 'bytes'
},
"oldHttpProtocol": {
"label": "HTTP protocols",
+23 -26
View File
@@ -1,38 +1,23 @@
{
"globalScore": {
"pageWeight": 2,
"images": 2,
"domComplexity": 1,
"javascriptComplexity": 2,
"badJavascript": 2,
"jQuery": 0.5,
"cssComplexity": 0.5,
"badCSS": 1,
"fonts": 1,
"serverConfig": 1
},
"categories": {
"pageWeight": {
"label": "Network",
"label": "Page weight",
"policies": {
"totalWeight": 5,
"totalRequests": 2,
"domains": 3,
"imageOptimization": 2,
"imagesTooLarge": 1,
"compression": 2,
"fileMinification": 2,
"identicalFiles": 2,
"emptyRequests": 3,
"notFound": 2
"fileMinification": 2
}
},
"images": {
"label": "Images",
"requests": {
"label": "Requests",
"policies": {
"imagesNotOptimized": 2,
"imagesOldFormat": 1,
"imagesScaledDown": 2,
"imagesExcessiveDensity": 0.25,
"imagesWithIncorrectSizesParam": 1,
"totalRequests": 2,
"domains": 3,
"notFound": 2,
"identicalFiles": 2,
"emptyRequests": 3,
"lazyLoadableImagesBelowTheFold": 2,
"hiddenImages": 1
}
@@ -116,5 +101,17 @@
"cachingTooShort": 1
}
}
},
"globalScore": {
"pageWeight": 3,
"requests": 2,
"domComplexity": 2,
"javascriptComplexity": 2,
"badJavascript": 2,
"jQuery": 0.5,
"cssComplexity": 0.5,
"badCSS": 1,
"fonts": 1,
"serverConfig": 1
}
}
+1 -8
View File
@@ -57,16 +57,9 @@ var RulesChecker = function() {
data.toolsResults[policy.tool].offenders[metricName]) {
offenders = data.toolsResults[policy.tool].offenders[metricName];
}
// It is possible to declare a transformation function for the main metric value.
// The function should
if (policy.valueTransformFn) {
rule.value = policy.valueTransformFn(offenders);
}
var offendersObj = {};
// It is possible to declare a transformation function for the offenders.
// The function should take an array of strings as single parameter and return a string.
if (policy.offendersTransformFn) {
+80 -9
View File
@@ -1,19 +1,90 @@
var debug = require('debug')('ylt:screenshotHandler');
var sharp = require('sharp');
var debug = require('debug')('ylt:screenshotHandlerAgent');
var Jimp = require('jimp');
var Q = require('q');
var fs = require('fs');
var path = require('path');
// Disable sharp cache to reduce the "disk is full" error on Amazon Lambda
sharp.cache(false);
var screenshotHandler = function() {
this.findAndOptimizeScreenshot = async function(tmpScreenshotPath, width) {
return sharp(tmpScreenshotPath)
.resize({width: 600})
.jpeg({quality: 85})
.toBuffer();
this.findAndOptimizeScreenshot = function(tmpScreenshotPath, width) {
var that = this;
debug('Starting screenshot transformation');
return this.openImage(tmpScreenshotPath)
.then(function(image) {
that.deleteTmpFile(tmpScreenshotPath);
return that.resizeImage(image, width);
})
.then(this.toBuffer);
};
this.openImage = function(imagePath) {
var deferred = Q.defer();
Jimp.read(imagePath, function(err, image){
if (err) {
debug('Could not open imagePath %s', imagePath);
debug(err);
deferred.reject(err);
} else {
debug('Image correctly open');
deferred.resolve(image);
}
});
return deferred.promise;
};
this.resizeImage = function(image, newWidth) {
var deferred = Q.defer();
var currentWidth = image.bitmap.width;
if (currentWidth > 0) {
var ratio = newWidth / currentWidth;
image.scale(ratio, function(err, image){
if (err) {
debug('Could not resize image');
debug(err);
deferred.reject(err);
} else {
debug('Image correctly resized');
deferred.resolve(image);
}
});
} else {
deferred.reject('Could not resize an empty image');
}
return deferred.promise;
};
this.toBuffer = function(image) {
var deferred = Q.defer();
image.quality(85).getBuffer(Jimp.MIME_JPEG, function(err, buffer){
if (err) {
debug('Could not save image to buffer');
debug(err);
deferred.reject(err);
} else {
debug('Image correctly transformed to buffer');
deferred.resolve(buffer);
}
});
return deferred.promise;
};
-7
View File
@@ -47,7 +47,6 @@ var PhantomasWrapper = function() {
// Mandatory
'analyze-css': true,
'analyze-images': true,
'ignoreSslErrors': true, // until Phantomas 2.1
'ignore-ssl-errors': true // for Phantomas >= 2.2
};
@@ -81,12 +80,6 @@ var PhantomasWrapper = function() {
offenders: results.getAllOffenders()
};
// Special rules here
if (task.options.device !== 'phone') {
delete json.metrics.imagesExcessiveDensity;
delete json.offenders.imagesExcessiveDensity;
}
deferred.resolve(json);
}).
catch(res => {
+54 -23
View File
@@ -1,12 +1,20 @@
var debug = require('debug')('ylt:contentTypeChecker');
var Q = require('q');
var FileType = require('file-type');
var isSvg = require('is-svg');
var isJson = require('is-json');
var debug = require('debug')('ylt:contentTypeChecker');
var Q = require('q');
var isJpg = require('is-jpg');
var isPng = require('is-png');
var isSvg = require('is-svg');
var isGif = require('is-gif');
var isWebp = require('is-webp');
var isWoff = require('is-woff');
var isWoff2 = require('is-woff2');
var isOtf = require('is-otf');
var isTtf = require('is-ttf');
var isEot = require('is-eot');
var isJson = require('is-json');
var ContentTypeChecker = function() {
async function checkContentType(entry) {
function checkContentType(entry) {
var deferred = Q.defer();
// Setting isSomething values:
@@ -47,12 +55,12 @@ var ContentTypeChecker = function() {
var foundType;
try {
foundType = await findContentType(entry.weightCheck.bodyBuffer);
foundType = findContentType(entry.weightCheck.bodyBuffer);
// If it's an image or a font, then rewrite.
if (foundType !== null && (foundType.type === 'image' || foundType.type === 'webfont' || foundType.type === 'json')) {
if (foundType.type !== entry.type) {
debug('Content type %s is wrong for %s. It should be %s.', entry.type, entry.url, foundType.type);
debug('Content type %s is wrong for %s. It should be %s.', entry.type, entry.ulr, foundType.type);
}
rewriteContentType(entry, foundType);
}
@@ -68,21 +76,52 @@ var ContentTypeChecker = function() {
return deferred.promise;
}
async function findContentType(bodyBuffer) {
function findContentType(bodyBuffer) {
var bodyStr = bodyBuffer.toString();
if (isJpg(bodyBuffer)) {
return contentTypes.jpeg;
}
if (isPng(bodyBuffer)) {
return contentTypes.png;
}
// https://github.com/sindresorhus/is-svg/issues/7
if (/<svg/.test(bodyStr) && isSvg(bodyStr)) {
return contentTypes.svg;
}
if (isJson(bodyStr)) {
return contentTypes.json;
if (isGif(bodyBuffer)) {
return contentTypes.gif;
}
const type = await FileType.fromBuffer(bodyBuffer);
if (type && type.ext && contentTypes[type.ext]) {
return contentTypes[type.ext];
if (isWebp(bodyBuffer)) {
return contentTypes.webp;
}
if (isWoff(bodyBuffer)) {
return contentTypes.woff;
}
if (isWoff2(bodyBuffer)) {
return contentTypes.woff2;
}
if (isOtf(bodyBuffer)) {
return contentTypes.otf;
}
if (isTtf(bodyBuffer)) {
return contentTypes.ttf;
}
if (isEot(bodyBuffer)) {
return contentTypes.eot;
}
if (isJson(bodyStr)) {
return contentTypes.json;
}
return null;
@@ -107,7 +146,7 @@ var ContentTypeChecker = function() {
}
var contentTypes = {
jpg: {
jpeg: {
type: 'image',
mimes: ['image/jpeg'],
updateFn: function(entry) {
@@ -148,14 +187,6 @@ var ContentTypeChecker = function() {
entry.isImage = true;
}
},
avif: {
type: 'image',
mimes: ['image/avif'],
updateFn: function(entry) {
entry.type = 'image';
entry.isImage = true;
}
},
woff: {
type: 'webfont',
mimes: ['application/x-font-woff', 'application/font-woff', 'font/woff'],
-4
View File
@@ -43,10 +43,6 @@ var ImageDimensions = function() {
return entry.isImage && entry.contentType === 'image/png';
}
function isWebP(entry) {
return entry.isImage && entry.contentType === 'image/webp';
}
return {
getDimensions: getDimensions
};
+14 -14
View File
@@ -14,13 +14,13 @@ var async = require('async');
var request = require('request');
var md5 = require('md5');
//var imageOptimizer = require('./imageOptimizer');
var imageOptimizer = require('./imageOptimizer');
var fileMinifier = require('./fileMinifier');
var gzipCompressor = require('./gzipCompressor');
var brotliCompressor = require('./brotliCompressor');
var contentTypeChecker = require('./contentTypeChecker');
var fontAnalyzer = require('./fontAnalyzer');
//var imageDimensions = require('./imageDimensions');
var imageDimensions = require('./imageDimensions');
var Redownload = function() {
@@ -76,9 +76,9 @@ var Redownload = function() {
.then(contentTypeChecker.checkContentType)
//.then(imageOptimizer.optimizeImage)
.then(imageOptimizer.optimizeImage)
//.then(imageDimensions.getDimensions)
.then(imageDimensions.getDimensions)
.then(fileMinifier.minifyFile)
@@ -151,12 +151,12 @@ var Redownload = function() {
});
// Image compression
//offenders.imageOptimization = listImagesNotOptimized(results);
//metrics.imageOptimization = offenders.imageOptimization.totalGain;
offenders.imageOptimization = listImagesNotOptimized(results);
metrics.imageOptimization = offenders.imageOptimization.totalGain;
// Image width
//offenders.imagesTooLarge = listImagesTooLarge(results, data.params.options.device);
//metrics.imagesTooLarge = offenders.imagesTooLarge.length;
offenders.imagesTooLarge = listImagesTooLarge(results, data.params.options.device);
metrics.imagesTooLarge = offenders.imagesTooLarge.length;
// File minification
offenders.fileMinification = listFilesNotMinified(results);
@@ -341,7 +341,7 @@ var Redownload = function() {
}
/*function listImagesNotOptimized(requests) {
function listImagesNotOptimized(requests) {
var results = {
totalGain: 0,
images: []
@@ -396,9 +396,9 @@ var Redownload = function() {
}
});
return results;
}*/
}
/*function listImagesTooLarge(requests, device) {
function listImagesTooLarge(requests, device) {
var results = [];
requests.forEach(function(req) {
@@ -423,7 +423,7 @@ var Redownload = function() {
});
return results;
}*/
}
function listFilesNotMinified(requests) {
@@ -819,9 +819,9 @@ var Redownload = function() {
debug('Downloading %s', entry.url);
// Always add compression and webp/avif headers before sending, in case the server listens to them
// Always add compression and webp headers before sending, in case the server listens to them
var reqHeaders = [];
reqHeaders['Accept'] = '*/*,image/webp,image/avif';
reqHeaders['Accept'] = '*/*,image/webp';
reqHeaders['Accept-Encoding'] = 'gzip, deflate, br';
reqHeaders['Connection'] = 'keep-alive';
reqHeaders['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36';
+12 -4
View File
@@ -16,7 +16,7 @@
"yellowlabtools": "./bin/cli.js"
},
"engines": {
"node": ">= 18.0"
"node": ">= 16.0"
},
"main": "./lib/index.js",
"dependencies": {
@@ -26,7 +26,6 @@
"css-mq-parser": "0.0.3",
"debug": "4.3.4",
"easyxml": "2.0.1",
"file-type": "16.5.3",
"fontkit": "2.0.2",
"html-minifier": "4.0.0",
"image-size": "1.0.2",
@@ -35,15 +34,24 @@
"imagemin-jpegtran": "7.0.0",
"imagemin-optipng": "8.0.0",
"imagemin-svgo": "9.0.0",
"is-eot": "1.0.0",
"is-gif": "3.0.0",
"is-jpg": "2.0.0",
"is-json": "2.0.1",
"is-otf": "0.1.2",
"is-png": "1.1.0",
"is-svg": "3.0.0",
"is-ttf": "0.2.2",
"is-webp": "1.0.1",
"is-woff": "1.0.3",
"is-woff2": "1.0.0",
"jimp": "0.22.8",
"md5": "2.3.0",
"meow": "5.0.0",
"parse-color": "1.0.0",
"phantomas": "2.10.0",
"phantomas": "2.8.0",
"q": "1.5.1",
"request": "2.88.2",
"sharp": "0.32.6",
"ttf2woff2": "5.0.0",
"uglify-js": "3.17.4",
"woff-tools": "0.1.0"
+5 -5
View File
@@ -10,11 +10,11 @@ describe('contentTypeChecker', function() {
var svgImageContent = fs.readFileSync(path.resolve(__dirname, '../www/svg-image.svg'));
var cssFileContent = fs.readFileSync(path.resolve(__dirname, '../www/unminified-stylesheet.css'));
it('detect the right content type', async function() {
(await contentTypeChecker.findContentType(jpgImageContent)).mimes.should.deep.equal(['image/jpeg']);
(await contentTypeChecker.findContentType(pngImageContent)).mimes.should.deep.equal(['image/png']);
(await contentTypeChecker.findContentType(svgImageContent)).mimes.should.deep.equal(['image/svg+xml']);
should.equal(await contentTypeChecker.findContentType(cssFileContent), null);
it('detect the right content type', function() {
contentTypeChecker.findContentType(jpgImageContent).mimes.should.deep.equal(['image/jpeg']);
contentTypeChecker.findContentType(pngImageContent).mimes.should.deep.equal(['image/png']);
contentTypeChecker.findContentType(svgImageContent).mimes.should.deep.equal(['image/svg+xml']);
should.equal(contentTypeChecker.findContentType(cssFileContent), null);
});
});
+17 -1
View File
@@ -82,6 +82,13 @@ describe('redownload', function() {
data.toolsResults.redownload.offenders.totalWeight.byType.image.requests.length.should.equal(2);
data.toolsResults.redownload.offenders.totalWeight.byType.other.requests.length.should.equal(1);
data.toolsResults.redownload.offenders.should.have.a.property('imageOptimization');
data.toolsResults.redownload.offenders.imageOptimization.totalGain.should.be.above(0);
data.toolsResults.redownload.offenders.imageOptimization.images.length.should.equal(2);
data.toolsResults.redownload.offenders.should.have.a.property('imagesTooLarge');
data.toolsResults.redownload.offenders.imagesTooLarge.length.should.equal(0);
data.toolsResults.redownload.offenders.should.have.a.property('compression');
data.toolsResults.redownload.offenders.compression.totalGain.should.be.above(0);
data.toolsResults.redownload.offenders.compression.files.length.should.equal(5);
@@ -160,9 +167,18 @@ describe('redownload', function() {
redownload.redownloadEntry(entry)
.then(function(newEntry) {
newEntry.weightCheck.bodySize.should.equal(4193);
newEntry.weightCheck.bodyBuffer.should.deep.equal(fileContent);
done();
// Opening the image in jimp to check if the format is good
var Jimp = require('jimp');
Jimp.read(newEntry.weightCheck.bodyBuffer, function(err, image) {
image.bitmap.width.should.equal(620);
image.bitmap.height.should.equal(104);
done(err);
});
})
.fail(function(err) {
Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB