From 4fcb00ef04aefd09d37f5a1aa5a53775d132beb1 Mon Sep 17 00:00:00 2001 From: Dimitris Kazakos Date: Thu, 14 Nov 2024 20:25:23 +0200 Subject: [PATCH] Avoid resizing images when they already have the desired size (#1027) --- src/utils/image.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils/image.js b/src/utils/image.js index 33bdf11d8..73114b13b 100644 --- a/src/utils/image.js +++ b/src/utils/image.js @@ -316,6 +316,11 @@ export class RawImage { resample = 2, } = {}) { + // Do nothing if the image already has the desired size + if (this.width === width && this.height === height) { + return this; + } + // Ensure resample method is a string let resampleMethod = RESAMPLING_MAPPING[resample] ?? resample; @@ -742,4 +747,4 @@ export class RawImage { } }); } -} \ No newline at end of file +}