Skip to content

Commit 4fcb00e

Browse files
authored
Avoid resizing images when they already have the desired size (#1027)
1 parent 705cfc4 commit 4fcb00e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/utils/image.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,11 @@ export class RawImage {
316316
resample = 2,
317317
} = {}) {
318318

319+
// Do nothing if the image already has the desired size
320+
if (this.width === width && this.height === height) {
321+
return this;
322+
}
323+
319324
// Ensure resample method is a string
320325
let resampleMethod = RESAMPLING_MAPPING[resample] ?? resample;
321326

@@ -742,4 +747,4 @@ export class RawImage {
742747
}
743748
});
744749
}
745-
}
750+
}

0 commit comments

Comments
 (0)