有没有人知道脚本来验证给定图像的文件格式是什么.目前我正在填充图像对象,查看它的高度,宽度和分辨率.我没有看到解释文件格式的此对象的任何特定属性.
我想查看jpg,AI,PSD,High Jes Jpg,Bitmap和Tiff.
这是我目前的脚本:
protected bool IsValidImage(HttpPostedFileBase file, string fileName) {
//verify that the image is no more than 648 wide and 648 pixels tall
Image imgPhoto = Image.FromStream(file.InputStream);
if (imgPhoto.Width > 648)
return false;
if (imgPhoto.Height > 648)
return false;
if (imgPhoto.HorizontalResolution != 72 || imgPhoto.VerticalResolution != 72)
return false;
return true;
}
Run Code Online (Sandbox Code Playgroud)
提前致谢