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();

  /*         取图片尺寸         */
 

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注