我看同事使用JAVA调用AP使用imagemagick生成缩略图而且很清楚,在C#中怎么使用啊?

解决方案 »

  1.   

    以下是写版权和生成缩略图的详细C#代码public partial class smallImg : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Stream s = File.Open(Server.MapPath("~/")+ "/s_3.gif", FileMode.Open, FileAccess.Read, FileShare.None);
            byte[] b = new byte[(int)s.Length];
            s.Read(b, 0, (int)s.Length);                Response.OutputStream.Write(b, 0, (int)s.Length);
            s.Close();    }        protected void Button1_Click1(object sender, EventArgs e)
        {
          
            if (File1.PostedFile.FileName != null)
            {
              
                string namestr = Path.GetFileName(File1.PostedFile.FileName);//提取文件名   
               
                File1.PostedFile.SaveAs(Server.MapPath(".") + @"\" + namestr);
               
                Image2.Visible = true;
                
                Image2.ImageUrl =  namestr;
               
                System.Drawing.Image image, aNewImage;
               
                image = System.Drawing.Image.FromStream(File1.PostedFile.InputStream);
               
                decimal width = image.Width;
               
                decimal height = image.Height;
              
                int newwidth, newheight;
               
                if (width > height)
                {
                    newwidth = 150;
                    newheight = (int)(height / width * 150);
                }
                else
                {
                    newheight = 150;
                    newwidth = (int)(width / height * 150);
                }
                aNewImage = image.GetThumbnailImage(newwidth, newheight, null, IntPtr.Zero);
                Bitmap output = new Bitmap(aNewImage);
                Graphics g = Graphics.FromImage(output);
                g.DrawString("LonoL", new Font("Courier New", 9), new SolidBrush(Color.Red), 60, 60);//写版权信息及文本格式及位置
                output.Save(Server.MapPath("~/") + @"\s_" + namestr, System.Drawing.Imaging.ImageFormat.Jpeg);
                Image1.Visible = true;
                Image1.ImageUrl = "s_" + namestr;           
            }
            else
            {
                Response.Write("B");
            }
        }
    }
      

  2.   

    using System.Drawing;
    using System.Drawing.Imaging;
    using System.IO;
    需要被引用的
      

  3.   

    我是想用第三方的imagemagick 这个东西生成 汗!
      

  4.   

    不知道掉哪个API。 有过此经验的朋友留个方法啊