简体   繁体   中英

Get Image dimensions in c# asp.net core (framework 4.6.1)

Any idea on how to get an image dimensions in asp.net core, knowing that System.Drawing.Image doesn't work on this version. This is how I am actually reading the image:

byte[] data = File.ReadAllBytes("path_to_image");
return data;

ie: Can I find the Height and Width of an image in its byte[] representaion?

Any help in how to rotate the image is also welcome.

You want bytes 11-12 for Horizontal resolution, and 13-14 for Vertical resolution. Assuming you're talking about a JPEG image. And byte 10 gives you the unit type (dots per inch or dots per cm)

https://www.w3.org/Graphics/JPEG/jfif3.pdf

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM