From 95e3223390b128b98460c62ed8696257d66caed3 Mon Sep 17 00:00:00 2001 From: Ayush Raj Chourasia <147280788+Ayush-Raj-Chourasia@users.noreply.github.com> Date: Sat, 4 Oct 2025 18:54:45 +0530 Subject: [PATCH] Update image-asset-common.ts --- .../core/image-asset/image-asset-common.ts | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/packages/core/image-asset/image-asset-common.ts b/packages/core/image-asset/image-asset-common.ts index 798727dd3e..db3b52407d 100644 --- a/packages/core/image-asset/image-asset-common.ts +++ b/packages/core/image-asset/image-asset-common.ts @@ -47,17 +47,26 @@ export function getAspectSafeDimensions(sourceWidth, sourceHeight, reqWidth, req } export function getRequestedImageSize(src: { width: number; height: number }, options: ImageAssetOptions): { width: number; height: number } { - let reqWidth = options.width || Math.min(src.width, Screen.mainScreen.widthPixels); - let reqHeight = options.height || Math.min(src.height, Screen.mainScreen.heightPixels); - if (options && options.keepAspectRatio) { - const safeAspectSize = getAspectSafeDimensions(src.width, src.height, reqWidth, reqHeight); - reqWidth = safeAspectSize.width; - reqHeight = safeAspectSize.height; - } + // Coerce width and height to numbers if they are strings + let reqWidth = options.width || Math.min(src.width, Screen.mainScreen.widthPixels); + let reqHeight = options.height || Math.min(src.height, Screen.mainScreen.heightPixels); - return { - width: reqWidth, - height: reqHeight, - }; + if (typeof reqWidth === 'string') { + reqWidth = parseInt(reqWidth, 10); + } + if (typeof reqHeight === 'string') { + reqHeight = parseInt(reqHeight, 10); + } + + if (options && options.keepAspectRatio) { + const safeAspectSize = getAspectSafeDimensions(src.width, src.height, reqWidth, reqHeight); + reqWidth = safeAspectSize.width; + reqHeight = safeAspectSize.height; + } + + return { + width: reqWidth, + height: reqHeight, + }; }