I had originally wrote this to resize a picture for an application that would use pictures (ie; avatar/profile pictures). All it does is resize it to your specified dimensions and displays it into a picture box.

PHP Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

public static class 
Pictures
{
    private static 
Size GenerateImageDimensions(int currWint currHint destWint destH)
    {
        
double multiplier 0;
        
string layout;
        if (
currH currWlayout "portrait";
        else 
layout "landscape";

        switch (
layout.ToLower())
        {
            case 
"portrait":
                if (
destH destW)
                {
                    
multiplier = (double)destW / (double)currW;
                }

                else
                {
                    
multiplier = (double)destH / (double)currH;
                }
                break;
            case 
"landscape":
                if (
destH destW)
                {
                    
multiplier = (double)destW / (double)currW;
                }

                else
                {
                    
multiplier = (double)destH / (double)currH;
                }
                break;
        }
        return new 
Size((int)(currW multiplier), (int)(currH multiplier));
    }

    public static 
void SetImage(PictureBox pb)
    {
        try
        {
            
Image img pb.Image;
            
Size imgSize GenerateImageDimensions(img.Widthimg.Heightpb.Size.Widthpb.Size.Height);
            
Bitmap finalImg = new Bitmap(imgimgSize.WidthimgSize.Height);
            
Graphics gfx Graphics.FromImage(img);
            
gfx.InterpolationMode InterpolationMode.HighQualityBicubic;
            
pb.Image null;
            
pb.SizeMode PictureBoxSizeMode.CenterImage;
            
pb.Image finalImg;
        }
        catch (
System.Exception e)
        {
            
MessageBox.Show(e.Message);
        }
    }