知道图片(网上的)地址:http://profile.csdn.net/hery2002/picture/3.jpg
要如何才能获取他的width和height

解决方案 »

  1.   

    找到了创建一个image对像,就可以取得高宽了,呵呵!!!
    3 楼stephenZL(我爱C#,HOHO~~~)回复于 2005-01-12 12:09:52 得分 50
    Image   im   =   Image.FromFile(你图片的路径);   
      im.width   
      im.height
      

  2.   


    System.Drawing.Image img = System.Drawing.Image.FromFile("http://profile.csdn.net/YZJ_JAKIN/picture/2.jpg");
    int height = img.Height;
    int width = img.Width;
    Response.Write("<script>alert('"+width+"'+'*'+'"+height+"')</script>");异常详细信息: System.ArgumentException: 不支持 URI 格式。
      

  3.   

    只能下载到本地...读数据流,创建Image对象...
      

  4.   

    在用把问题复杂化用JS就可以了http://bbs.jingdiansheji.com/Show_16.html这我是的代码,还有例子下载。你可以看看。如果是C#就可以用System.Drawing.Image img = System.Drawing.Image.FromFile("http://profile.csdn.net/YZJ_JAKIN/picture/2.jpg"); 
    int height = img.Height; 
    int width = img.Width; 
    Response.Write(" <script>alert('"+width+"'+'*'+'"+height+"') </script>"); 
      

  5.   

    呵呵,参数不是URI,而是文件系统中的相对路径.
    形如,System.Drawing.Image img = System.Drawing.Image.FromFile("~/YZJ_JAKIN/picture/2.jpg");
    FromFile从字面上楼主就可以理解出来啊
      

  6.   

    这是MSDN上的代码:private void Button2_Click(System.Object sender, System.EventArgs e)
    {
        try
        {
            Bitmap image1 = (Bitmap) Image.FromFile(@"C:\Documents and Settings\" +
                @"All Users\Documents\My Music\music.bmp", true);        TextureBrush texture = new TextureBrush(image1);
            texture.WrapMode = System.Drawing.Drawing2D.WrapMode.Tile;
            Graphics formGraphics = this.CreateGraphics();
            formGraphics.FillEllipse(texture, 
                new RectangleF(90.0F, 110.0F, 100, 100));
            formGraphics.Dispose();    }
        catch(System.IO.FileNotFoundException)
        {
            MessageBox.Show("There was an error opening the bitmap." +
                "Please check the path.");
        }}
    你如果从网上的图片,如果你要在服务器端判断,你可以先下载到你的服务器某一目录的文件夹中好了.
      

  7.   

    要这样才行 System.Net.HttpWebRequest imgc = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(plurltxt.Text);
                System.Net.HttpWebResponse imgg = (System.Net.HttpWebResponse)imgc.GetResponse();
                System.Drawing.Image img = System.Drawing.Image.FromStream(imgg.GetResponseStream());
      

  8.   

    这样的问题用脚本比较好
    var objImg=new Image();
    objImg.src="http://profile.csdn.net/hery2002/picture/3.jpg";
    window.alert(objImg.width);
    window.alert(objImg.height);