From 40d1ae3da78e17f5344f861606831c7346549ee9 Mon Sep 17 00:00:00 2001 From: Eduardo Giacometti De Patta Date: Tue, 10 Sep 2024 15:07:15 -0300 Subject: [PATCH] refactor: rename variable for consistency in image processing utility --- components/utils/resize-image.utils.test.ts | 8 ++++---- components/utils/resize-image.utils.ts | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/components/utils/resize-image.utils.test.ts b/components/utils/resize-image.utils.test.ts index 1dc53f3..b200d2f 100644 --- a/components/utils/resize-image.utils.test.ts +++ b/components/utils/resize-image.utils.test.ts @@ -54,7 +54,7 @@ describe("Image Processing Functions", () => { const result = await resizeImage({ img, width: 500, - maintainAspectRatio: true, + preserveAspectRatio: true, format: "png", quality: 1, }); @@ -69,7 +69,7 @@ describe("Image Processing Functions", () => { const result = await resizeImage({ img, height: 250, - maintainAspectRatio: true, + preserveAspectRatio: true, format: "jpeg", quality: 0.8, }); @@ -99,7 +99,7 @@ describe("Image Processing Functions", () => { processImageFile({ file: mockFile, format: "jpeg", - maintainAspectRatio: true, + preserveAspectRatio: true, quality: 0.8, setWidth, setHeight, @@ -154,7 +154,7 @@ describe("Image Processing Functions", () => { format: "jpeg", height: 400, width: 600, - maintainAspectRatio: true, + preserveAspectRatio: true, quality: 0.8, setOutput, }); diff --git a/components/utils/resize-image.utils.ts b/components/utils/resize-image.utils.ts index a876f73..d7809eb 100644 --- a/components/utils/resize-image.utils.ts +++ b/components/utils/resize-image.utils.ts @@ -5,14 +5,14 @@ interface ResizeImageOptions { height?: number; format?: Format; quality?: number; - maintainAspectRatio?: boolean; + preserveAspectRatio?: boolean; } export function resizeImage({ img, format, height, - maintainAspectRatio, + preserveAspectRatio, quality, width, }: ResizeImageOptions): Promise { @@ -37,7 +37,7 @@ export function resizeImage({ return; } - if (maintainAspectRatio) { + if (preserveAspectRatio) { const ratio = img.width / img.height; const dimensionMapper = { @@ -78,14 +78,14 @@ interface ProcessImageFileOptions { setOutput: (output: string) => void; format: Format; quality: number; - maintainAspectRatio: boolean; + preserveAspectRatio: boolean; done?: () => void; } export const processImageFile = ({ file, format, - maintainAspectRatio, + preserveAspectRatio, quality, setHeight, setOutput, @@ -105,7 +105,7 @@ export const processImageFile = ({ height: img.height, format, quality, - maintainAspectRatio, + preserveAspectRatio, }) .then(setOutput) .catch((error) => console.error(error)) @@ -163,7 +163,7 @@ interface HandleResizeImage { height: number | undefined; format: Format; quality: number; - maintainAspectRatio: boolean; + preserveAspectRatio: boolean; setOutput: (output: string) => void; } @@ -171,7 +171,7 @@ export const handleResizeImage = ({ file, format, height, - maintainAspectRatio, + preserveAspectRatio, quality, setOutput, width, @@ -187,7 +187,7 @@ export const handleResizeImage = ({ height, format, quality, - maintainAspectRatio, + preserveAspectRatio, }).then(setOutput); }; };