From 4a9b9c2c7788b6e1693155a10d03566dffe172e4 Mon Sep 17 00:00:00 2001 From: Tommaso Rossi Date: Thu, 29 Dec 2022 11:35:38 +0100 Subject: [PATCH] round image resize width and height --- packages/react/src/image-size.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/react/src/image-size.ts b/packages/react/src/image-size.ts index 974964d5..5a44932f 100644 --- a/packages/react/src/image-size.ts +++ b/packages/react/src/image-size.ts @@ -34,16 +34,19 @@ export function addImageSizeParametersToUrl({ let finalWidth: string; if (typeof width === 'string') { - finalWidth = (IMG_SRC_SET_SIZES[0] * multipliedScale).toString(); + finalWidth = Math.ceil(IMG_SRC_SET_SIZES[0] * multipliedScale).toString(); } else { - finalWidth = (Number(width) * multipliedScale).toString(); + finalWidth = Math.ceil(Number(width) * multipliedScale).toString(); } newUrl.searchParams.append('width', finalWidth); } if (height && typeof height === 'number') { - newUrl.searchParams.append('height', (height * multipliedScale).toString()); + newUrl.searchParams.append( + 'height', + Math.ceil(height * multipliedScale).toString() + ); } crop && newUrl.searchParams.append('crop', crop);