none
How can I programmatically resize images? RRS feed

  • Question

  • I have images from AD at 96x95. Is there a way to programmatically resize these images to 175x175 without losing image quality? I have never done this before, and wondering if this is even possible and if so has anyone had success doing this. 

    Thank you so much for your help.

    Monday, February 26, 2018 8:30 PM

All replies

  • not possible without losing image quality
    Monday, February 26, 2018 9:42 PM
  • Hi Spawn10,

    Try the link at codeproject

    Greetings Rinaldo


    Greetings from Amsterdam the Netherlands

    Monday, February 26, 2018 10:02 PM
  • Hi Spawn10,

    Thank you for posting here.

    You could not resize image without lose quality. As I know, SmoothingMode.HighQuality is a better way to reduce the lose of quality.

      int newWidth = 175;
                int newHeight = 175;
                Image srcImage = Image.FromFile("1.jpg");
                Bitmap newImage = new Bitmap(newWidth, newHeight);
                using (Graphics gr = Graphics.FromImage(newImage))
                {
                    gr.SmoothingMode = SmoothingMode.HighQuality;
                    gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
                    gr.DrawImage(srcImage, new Rectangle(0, 0, newWidth, newHeight));
    
                }
                newImage.Save("2.JPG");

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Stanly Fan Thursday, March 1, 2018 1:07 AM
    Tuesday, February 27, 2018 6:51 AM
    Moderator