how can I get image size (w x h) using Stream

后端 未结 3 1921
伪装坚强ぢ
伪装坚强ぢ 2021-02-04 04:11

I have this code i am using to read uploaded file, but i need to get size of image instead but not sure what code can i use

HttpFileCollection collection = _cont         


        
3条回答
  •  囚心锁ツ
    2021-02-04 04:41

    First you have to write the image:

    System.Drawing.Image image = System.Drawing.Image.FromStream (new System.IO.MemoryStream(byteArrayHere));
    

    and afterwards you have the :

    image.Height.ToString(); 
    

    and the

    image.Width.ToString();
    

    note: you might want to add a check to be sure it's an image that was uploaded?

提交回复
热议问题