c# asp.net 远程获取图片大小和尺寸

  /*         取图片大小         */
           HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(textBox4.Text);
            HttpWebResponse myRes = (HttpWebResponse)myReq.GetResponse();
            textBox1.Text = myRes.ContentLength.ToString();
            myRes.Close();
  /*         取图片大小         */

 

  /*         取图片尺寸         */

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(imgurl);
            WebResponse response = request.GetResponse();
            Stream resStream = response.GetResponseStream();
            System.Drawing.Image imgPhoto = System.Drawing.Image.FromStream(resStream);
            int sourceWidth = imgPhoto.Width;
            int sourceHeight = imgPhoto.Height;
            textBox1.Text = sourceHeight.ToString();

  /*         取图片尺寸         */
 

没有评论 to “c# asp.net 远程获取图片大小和尺寸”

留下评论:

昵称(必须):
邮箱地址 (不会被公开) (必须):
站点
评论 (必须)
XHTML: 您可以使用这些标记: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>