我的一个项目中用的

using System;
using System.IO;
using System.Drawing;

namespace Compoment
{
    
/// <summary>
    
/// ImageLib 的摘要说明。
    
/// </summary>

    public class ImageLib
    
{
        
private string _OrgFileName;
        
public string OrgFileName
        
{
            
get
            
{
                
return(_OrgFileName);
            }

            
set
            
{
                _OrgFileName
=value;
            }

        }


        
private string _OutFileName;
        
public string OutFileName
        
{
            
get
            
{
                
return(_OutFileName);
            }

            
set
            
{
                _OutFileName
=value;
            }

        }

        
public ImageLib()
        
{
            
//
            
// TODO: 在此处添加构造函数逻辑
            
//
        }


        
public ImageLib(string InFileName,string OutputFileName)
        
{
            
this.OrgFileName=InFileName;
            
this.OutFileName=OutputFileName;
        }


        
public void GetSmallPicture(string InFileName,string OutputFileName,int Width)
        
{
            
this.OrgFileName=InFileName;
            
this.OutFileName=OutputFileName;
            
if(File.Exists(this.OrgFileName))
            
{
                Image MyImage
=Image.FromFile(this.OrgFileName);
                Double Diff;
                Diff
=Convert.ToDouble(Decimal.Divide(MyImage.Height,MyImage.Width));
                Bitmap ImageOutput
=new Bitmap(MyImage,Width,Convert.ToInt32(Math.Ceiling(Width*Diff)));
                MyImage.Dispose();
                ImageOutput.Save(
this.OutFileName,System.Drawing.Imaging.ImageFormat.Jpeg);
                ImageOutput.Dispose();
            }

        }


        
public string GetSmallPicture(int Width)
        
{
            
return("");
        }


        
~ImageLib()
        
{

        }
        
    }

}