Skip to content

Fix rounding error which causes aspect ratio to not be retained#24

Open
johnnyoshika wants to merge 1 commit intoAzure-Samples:masterfrom
johnnyoshika:patch-1
Open

Fix rounding error which causes aspect ratio to not be retained#24
johnnyoshika wants to merge 1 commit intoAzure-Samples:masterfrom
johnnyoshika:patch-1

Conversation

@johnnyoshika
Copy link

@johnnyoshika johnnyoshika commented May 31, 2023

To reproduce the error, try uploading an image that's 1024x1024 pixels, then resize to 900px width. The width will be 900px but the height will be calculated as 1024px, because the divisor will be 1 due to integer truncation.

var divisor = 1024 / 900; // 1

The fix is:

var divisor = (decimal)image.Width / thumbnailWidth;

@johnnyoshika johnnyoshika changed the title Fix rounding error which caused aspect ratio to not be retained Fix rounding error which causes aspect ratio to not be retained May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant