2011-12-30 21 views
0

I持ってこのようなASP.NET MVC 3アプリケーションからSQL 2008に画像を保存し、アップロード:私も2列を持っている画像サイズを取得2008

... 
foreach (var httpFile in files) 
{ 
    TestProj.Models.File file = new TestProj.Models.File(); 

    using (BinaryReader reader = new BinaryReader(httpFile.InputStream)) 
    { 
      file.FileContent = reader.ReadBytes(httpFile.ContentLength); 
    } 

    file.FileName = httpFile.FileName; 
    file.FileExtension = (httpFile.FileName.Contains(".")) ?  
    httpFile.FileName.Substring(httpFile.FileName.LastIndexOf('.') +1) : ""; 
    file.FileSize = file.FileContent.Length; 
    file.ContentType = httpFile.ContentType; 

    _fileRepository.AddFile(file); 
... 

「幅」と「高さ」はアップロードされた画像のサイズを挿入したいのですが。

リーダーを使用して幅と高さを読み取る簡単な方法はありますか?事前に

おかげ

/ラッセ

答えて

2

使用Image.WidthとImage.Heightプロパティ。

Image img=Image.FromStream(stream); 
int width=img.Width; 
int height=img.Height; 
関連する問題