Skip to content

Commit 02c85aa

Browse files
committed
fix: fixed scale and scale_and_crop plugins
1 parent 4043bc1 commit 02c85aa

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/plugins/scale.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,28 @@ const PluginScale: Plugin = {
1212
config
1313
): Promise<sharp.Sharp> => {
1414
const convertDimension = instance.getAction('convertDimension');
15-
const convertBool = instance.getAction('convertBool');
1615

1716
const iWidth = metadata.width;
1817
const iHeight = metadata.height;
1918
const ratio = iWidth / iHeight;
2019

2120
const maxWidth = config.maxWidth
22-
? convertDimension(config.maxWidth, iWidth)
21+
? convertDimension(instance, config.maxWidth, iWidth)
2322
: 0;
2423
const maxHeight = config.maxHeight
25-
? convertDimension(config.maxHeight, iHeight)
24+
? convertDimension(instance, config.maxHeight, iHeight)
2625
: 0;
2726

28-
let width = config.width ? convertDimension(config.width, iWidth) : 0;
29-
let height = config.height ? convertDimension(config.height, iHeight) : 0;
27+
let width = config.width
28+
? convertDimension(instance, config.width, iWidth)
29+
: 0;
30+
let height = config.height
31+
? convertDimension(instance, config.height, iHeight)
32+
: 0;
3033

31-
const upscale = config.upscale ? convertBool(config.upscale) : true;
34+
const upscale = Object.prototype.hasOwnProperty.call(config, 'upscale')
35+
? config.upscale
36+
: true;
3237

3338
return new Promise<sharp.Sharp>((resolve, reject) => {
3439
try {

0 commit comments

Comments
 (0)