ASP.NET中获取图片的尺寸
public void GetImageSize(string FullFilePath) {//参数为图片文件的绝对路径 System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(FullFilePath); int width = bmp.Width; //宽 int height = bmp.Height; //高 }
获取上传的图片的尺寸
public void GetUploadImageSize() { //txt_Load为上传控件对象 System.Drawing.Image bmp = System.Drawing.Image.FromStream(txt_Load.PostedFile.InputStream); int width = bmp.Width; //宽 int height = bmp.Height; //高 }
JS里获取图片的尺寸
//有些浏览器获取不到本地的图片(安全设置) var getImageSize = function () { var image = new Image(); image.src = document.getElementById("test_img").src; var width = image.width; //宽 var height = image.height; //高 }
浙公网安备 33010602011771号