知道图片地址,要如何才能获取他的width和height 知道图片(网上的)地址:http://profile.csdn.net/hery2002/picture/3.jpg要如何才能获取他的width和height 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 找到了创建一个image对像,就可以取得高宽了,呵呵!!!3 楼stephenZL(我爱C#,HOHO~~~)回复于 2005-01-12 12:09:52 得分 50Image im = Image.FromFile(你图片的路径); im.width im.height 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 格式。 只能下载到本地...读数据流,创建Image对象... 在用把问题复杂化用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>"); 呵呵,参数不是URI,而是文件系统中的相对路径.形如,System.Drawing.Image img = System.Drawing.Image.FromFile("~/YZJ_JAKIN/picture/2.jpg");FromFile从字面上楼主就可以理解出来啊 这是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."); }}你如果从网上的图片,如果你要在服务器端判断,你可以先下载到你的服务器某一目录的文件夹中好了. 要这样才行 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()); 这样的问题用脚本比较好var objImg=new Image();objImg.src="http://profile.csdn.net/hery2002/picture/3.jpg";window.alert(objImg.width);window.alert(objImg.height); 求一脚本函数,使用onpropertychange这个事件触发 (~急)js中如何判断上传图片大小 在服务器端代码中如何实现用户交互 选择部门,全选改部门人员问题 高分求助邮件平台知识,分不够再加 如何部署aspnetdb.mdf ASP.NET 编译成DLL 与 不编译 ,哪种访问速度更快,速度能相差多少??? 打开解决方案出错? 出现如下错误是什么原因 droplist与数据库问题? ASP.NET AJAX在IE7中超时问题,而在FireFox则正常,请高手支招 在线等,首次进入跳出弹窗!IsPostBack
3 楼stephenZL(我爱C#,HOHO~~~)回复于 2005-01-12 12:09:52 得分 50
Image im = Image.FromFile(你图片的路径);
im.width
im.height
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 格式。
int height = img.Height;
int width = img.Width;
Response.Write(" <script>alert('"+width+"'+'*'+'"+height+"') </script>");
形如,System.Drawing.Image img = System.Drawing.Image.FromFile("~/YZJ_JAKIN/picture/2.jpg");
FromFile从字面上楼主就可以理解出来啊
{
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.");
}}
你如果从网上的图片,如果你要在服务器端判断,你可以先下载到你的服务器某一目录的文件夹中好了.
System.Net.HttpWebResponse imgg = (System.Net.HttpWebResponse)imgc.GetResponse();
System.Drawing.Image img = System.Drawing.Image.FromStream(imgg.GetResponseStream());
var objImg=new Image();
objImg.src="http://profile.csdn.net/hery2002/picture/3.jpg";
window.alert(objImg.width);
window.alert(objImg.height);