Skip to content

Commit

Permalink
Missing brotli compression size with cached image.
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Nov 1, 2023
1 parent 109e029 commit 982c33f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions img.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,20 @@ class Image {
for(let outputFormat in fullStats) {
for(let stat of fullStats[outputFormat]) {
if(this.options.useCache && fs.existsSync(stat.outputPath)){
stat.size = fs.statSync(stat.outputPath).size;
// Cached images already exist in output
let contents;
if(this.options.dryRun) {
stat.buffer = this.getFileContents();
contents = this.getFileContents();
stat.buffer = contents;
}

if(outputFormat === "svg" && this.options.svgCompressionSize === "br") {
if(!contents) {
contents = this.getFileContents();
}
stat.size = brotliSize.sync(contents);
} else {
stat.size = fs.statSync(stat.outputPath).size;
}

outputFilePromises.push(Promise.resolve(stat));
Expand Down

0 comments on commit 982c33f

Please sign in to comment.