Skip to content

Commit

Permalink
refactor: rename variable for consistency in image processing utility
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardoDePatta committed Sep 10, 2024
1 parent 8c64c79 commit 40d1ae3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions components/utils/resize-image.utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe("Image Processing Functions", () => {
const result = await resizeImage({
img,
width: 500,
maintainAspectRatio: true,
preserveAspectRatio: true,
format: "png",
quality: 1,
});
Expand All @@ -69,7 +69,7 @@ describe("Image Processing Functions", () => {
const result = await resizeImage({
img,
height: 250,
maintainAspectRatio: true,
preserveAspectRatio: true,
format: "jpeg",
quality: 0.8,
});
Expand Down Expand Up @@ -99,7 +99,7 @@ describe("Image Processing Functions", () => {
processImageFile({
file: mockFile,
format: "jpeg",
maintainAspectRatio: true,
preserveAspectRatio: true,
quality: 0.8,
setWidth,
setHeight,
Expand Down Expand Up @@ -154,7 +154,7 @@ describe("Image Processing Functions", () => {
format: "jpeg",
height: 400,
width: 600,
maintainAspectRatio: true,
preserveAspectRatio: true,
quality: 0.8,
setOutput,
});
Expand Down
18 changes: 9 additions & 9 deletions components/utils/resize-image.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
Expand All @@ -37,7 +37,7 @@ export function resizeImage({
return;
}

if (maintainAspectRatio) {
if (preserveAspectRatio) {
const ratio = img.width / img.height;

const dimensionMapper = {
Expand Down Expand Up @@ -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,
Expand All @@ -105,7 +105,7 @@ export const processImageFile = ({
height: img.height,
format,
quality,
maintainAspectRatio,
preserveAspectRatio,
})
.then(setOutput)
.catch((error) => console.error(error))
Expand Down Expand Up @@ -163,15 +163,15 @@ interface HandleResizeImage {
height: number | undefined;
format: Format;
quality: number;
maintainAspectRatio: boolean;
preserveAspectRatio: boolean;
setOutput: (output: string) => void;
}

export const handleResizeImage = ({
file,
format,
height,
maintainAspectRatio,
preserveAspectRatio,
quality,
setOutput,
width,
Expand All @@ -187,7 +187,7 @@ export const handleResizeImage = ({
height,
format,
quality,
maintainAspectRatio,
preserveAspectRatio,
}).then(setOutput);
};
};
Expand Down

0 comments on commit 40d1ae3

Please sign in to comment.