Skip to content

Commit af1f8de

Browse files
committed
Replace keepRatio option with crop option
1 parent 3c876e9 commit af1f8de

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function makeOptimizer(optimizerConfig, assetManager) {
7171
format,
7272
width,
7373
height,
74-
keepRatio,
74+
crop,
7575
quality,
7676
scale,
7777
suffix
@@ -89,7 +89,7 @@ function makeOptimizer(optimizerConfig, assetManager) {
8989
targetDir,
9090
fingerprint,
9191
variant: {
92-
autorotate, format, width, height, keepRatio, quality, scale, suffix
92+
autorotate, format, width, height, crop, quality, scale, suffix
9393
}
9494
});
9595
};
@@ -136,7 +136,7 @@ async function optimizeSVG(sourcePath) {
136136
}
137137

138138
async function optimizeBitmap(sourcePath, format,
139-
{ autorotate, width, height, scale, quality, keepRatio = true }) {
139+
{ autorotate, width, height, scale, quality, crop }) {
140140
let image = sharp(sourcePath);
141141
if(autorotate) {
142142
image.rotate();
@@ -148,7 +148,7 @@ async function optimizeBitmap(sourcePath, format,
148148
}
149149

150150
if(width || height) {
151-
let fit = keepRatio ? "inside" : "cover";
151+
let fit = crop ? "cover" : "inside";
152152
image.resize({ width: width, height: height, fit: sharp.fit[fit] });
153153
}
154154

test/test_resizing/faucet.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = {
1818
target: "./dist",
1919
width: 300,
2020
height: 300,
21-
keepRatio: false,
21+
crop: true,
2222
suffix: "-square"
2323
}],
2424
plugins: [path.resolve(__dirname, "../..")]

0 commit comments

Comments
 (0)