Skip to content

Commit 77c71c3

Browse files
authored
fix: simplify resize percentage calculations (#387)
- simplify resize percentage calculations by removing redundant multiplications
1 parent 7bed559 commit 77c71c3

File tree

1 file changed

+4
-4
lines changed
  • packages/wasm-image-processor/src

1 file changed

+4
-4
lines changed

packages/wasm-image-processor/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ function resize(image: photon.PhotonImage, width: number, height: number, usePer
1010
const imageWidth = image.get_width();
1111
const imageHeight = image.get_height();
1212

13-
const widthPercent = usePercent ? width : (width * 100.0) / imageWidth;
14-
const heightPercent = usePercent ? height : (height * 100.0) / imageHeight;
13+
const widthPercent = usePercent ? width : width / imageWidth;
14+
const heightPercent = usePercent ? height : height / imageHeight;
1515

16-
const newWidth = (imageWidth * widthPercent) / 100;
17-
const newHeight = (imageHeight * heightPercent) / 100;
16+
const newWidth = imageWidth * widthPercent;
17+
const newHeight = imageHeight * heightPercent;
1818

1919
return photon.resize(image, newWidth, newHeight, 1);
2020
}

0 commit comments

Comments
 (0)