Skip to content

Commit

Permalink
Skip encoding images which are being resized
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparsz committed Mar 22, 2022
1 parent 80efb7a commit cc708d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions gulp/image-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,22 @@ class ImageTransform {
const resizeConfig = this.config.resize;

if (resizeConfig) {
const fileResize = {};
let willResize = false;

for (let glob in resizeConfig) {
if (minimatch(relativeFileName, glob)) {
Object.assign(fileSettings.resize, resizeConfig[glob]);
Object.assign(fileResize, resizeConfig[glob]);
willResize = true;
}
}

// Add encoded image count * resized count
fileSettings.count += fileSettings.encodeCount * (Object.keys(fileSettings.resize).length - 1);
// By overwriting resize we skip original image since it's not needed
if (willResize) {
fileSettings.count = fileSettings.encodeCount * (Object.keys(fileResize).length);
fileSettings.resize = fileResize;
}
}

return fileSettings;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@videinfra/static-website-builder-images-plugin",
"version": "2.2.5",
"version": "2.2.6",
"description": "Image resize and format converted",
"license": "MIT",
"engines": {
Expand Down

0 comments on commit cc708d0

Please sign in to comment.