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

  • SEARCH
  • Home
  • 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 882509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:26:15+00:00 2026-05-15T12:26:15+00:00

I want to get an image from a user and re-size it to a

  • 0

I want to get an image from a user and re-size it to a specific size but the problem is :
I don’t know about the user’s image size and I have to re-size it to a certain size but deformation is burden over here.

how can I solve this problem? is there any algorithm according to that?
or is there any source code preferably in .net?
best regards.

  • 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-05-15T12:26:16+00:00Added an answer on May 15, 2026 at 12:26 pm

    As far as deformation, you could use a combination of cropping and resizing. Your user would help you with the cropping.

    I found this code on Code Project with a simple Google search of .net resize an image

    imgPhoto = FixedSize(imgPhotoVert, 300, 300);
    imgPhoto.Save(WorkingDirectory + 
        @"\images\imageresize_3.jpg", ImageFormat.Jpeg);
    imgPhoto.Dispose();
    ....
    static Image FixedSize(Image imgPhoto, int Width, int Height)
    {
        int sourceWidth = imgPhoto.Width;
        int sourceHeight = imgPhoto.Height;
        int sourceX = 0;
        int sourceY = 0;
        int destX = 0;
        int destY = 0; 
    
        float nPercent = 0;
        float nPercentW = 0;
        float nPercentH = 0;
    
        nPercentW = ((float)Width/(float)sourceWidth);
        nPercentH = ((float)Height/(float)sourceHeight);
        if(nPercentH < nPercentW)
        {
            nPercent = nPercentH;
            destX = System.Convert.ToInt16((Width - 
                          (sourceWidth * nPercent))/2);
        }
        else
        {
            nPercent = nPercentW;
            destY = System.Convert.ToInt16((Height - 
                          (sourceHeight * nPercent))/2);
        }
    
        int destWidth  = (int)(sourceWidth * nPercent);
        int destHeight = (int)(sourceHeight * nPercent);
    
        Bitmap bmPhoto = new Bitmap(Width, Height, 
                          PixelFormat.Format24bppRgb);
        bmPhoto.SetResolution(imgPhoto.HorizontalResolution, 
                         imgPhoto.VerticalResolution);
    
        Graphics grPhoto = Graphics.FromImage(bmPhoto);
        grPhoto.Clear(Color.Red);
        grPhoto.InterpolationMode = 
                InterpolationMode.HighQualityBicubic;
    
        grPhoto.DrawImage(imgPhoto, 
            new Rectangle(destX,destY,destWidth,destHeight),
            new Rectangle(sourceX,sourceY,sourceWidth,sourceHeight),
            GraphicsUnit.Pixel);
    
        grPhoto.Dispose();
        return bmPhoto;
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want just get Image( .JPG , .PNG , .Gif ) File from my
I want to get a thumbnail image for videos from Vimeo. When getting images
I want to get this image uploading script right, but for whatever reason it
I want to create a thumbnail from an image uploaded from user on webpage.
I want to load only certain images from HTML DOM, based on image width
I want to get some images from a movie and make a gif. What
I want to get some images from a flash webpage and I got the
I want to get the Bitmap from URL like - https://graph.facebook.com/100003506521332/picture I tried how-i-can-display-images-from-url-in-blackberry
I want to get RGB values of an image in many lighting conditions. To
I want to get the Height and Width of an Image.Currently what im doing

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.