如何检查行程和行程Fileuploader中图像的宽度 [英] How to check the legth& width of an image in fileuploader

查看:75
本文介绍了如何检查行程和行程Fileuploader中图像的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我们使用fileuploader上传图像,我想检查图像的高度和宽度.我想保存图像,如果它的尺寸为677x100,496x255和126px×129px ...我该如何检查高度和宽度....我想根据条件给出此尺寸....

I want to check the image height and width if we upload an image using fileuploader..i want to allow the image to save, if it having dimensions like 677x100,496x255 and 126px × 129px... how can i check the height and width ....i want to give this dimensions according to the conditions....

推荐答案

在保存图像之前调用此函数

Call this function just before saving the image

public bool ValidateFileDimensions()
 {
   using (System.Drawing.Image myImage = System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream))
   {
     return (myImage.Height == height && myImage.Width == width);
   }
 }


这篇关于如何检查行程和行程Fileuploader中图像的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆