Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9222553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:51:34+00:00 2026-06-18T03:51:34+00:00

How do you resize the width of a image in C# without resizing the

  • 0

How do you resize the width of a image in C# without resizing the height using image.resize()

When I do it this way:

image.Resize(width: 800, preserveAspectRatio: true,preventEnlarge:true);

This is the full code:

var imagePath = "";
var newFileName = "";
var imageThumbPath = "";
WebImage image = null;            
image = WebImage.GetImageFromRequest();
if (image != null)
{
    newFileName = Path.GetFileName(image.FileName);
    imagePath = @"pages/"+newFileName;
    image.Resize(width:800, preserveAspectRatio:true, preventEnlarge:true);
    image.Save(@"~/images/" + imagePath);
    imageThumbPath = @"pages/thumbnail/"+newFileName;
    image.Resize(width: 150, height:150, preserveAspectRatio:true, preventEnlarge:true);
    image.Save(@"~/images/" + imageThumbPath);
}

I get this error message:

No overload for method ‘Resize’ takes 3 arguments

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:51:35+00:00Added an answer on June 18, 2026 at 3:51 am

    The documentation is garbage, so I peeked at the source code. The logic they are using is to look at the values passed for height and width and compute aspect ratios for each comparing the new value to the current value. Whichever value (height or width) has the greater aspect ratio gets its value computed from the other value. Here’s the relevant snippet:

    double hRatio = (height * 100.0) / image.Height;
    double wRatio = (width * 100.0) / image.Width;
    if (hRatio > wRatio)
    {
        height = (int)Math.Round((wRatio * image.Height) / 100);
    }
    else if (hRatio < wRatio)
    {
        width = (int)Math.Round((hRatio * image.Width) / 100);
    }
    

    So, what that means is that, if you don’t want to compute the height value yourself, just pass in a height value that is very large.

    image.Resize(800, 100000, true, true);
    

    This will cause hRatio to be larger than wRatio and then height will be computed based on width.

    Since you have preventEnlarge set to true, you could just pass image.Height in.

    image.Resize(800, image.Height, true, true);
    

    Of course, it’s not difficult to just compute height yourself:

    int width = 800;
    int height = (int)Math.Round(((width * 1.0) / image.Width) * image.Height);
    image.Resize(width, height, false, true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to proportionally resize an image if the height and width
We need the ability to gracefully resize any photo/image to an exact width/height without
I am using a mx:Resize effect to change the width of an image in
I need to resize and crop an image to a specific width and height.
What is the best way to resize images using .NET, without losing the EXIF
I'm trying to resize a ccsprite image. My wanted resizing way is to decrease
I'm using the following code to resize an image so it fits inside a
I need to resize my image proportionately without changing aspect ratio.I have the code
Can i resize images in python to given height and width,i use python 2.5,
Hello everyone I am trying to resize an image of 700kb with imagecreatefromjpeg. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.