Width and Height of an image inside a jpg file can be retrieved by reading all file data into an Image.
System.Drawing.Image img = System.Drawing.Image.FromFile("a.jpg");
var w = img.Width
var h = img.Height
This is costly however and if only width and height are needed, there might be a better way.
So I wonder if there is a less resource intensive way to get the image dimensions. In my (common) scenario, the jpg is uploaded to the web server and the web application shall just get width and height and store that. I thought, the jpg file format might have width and height as easy readable metadata and if so, someone knows how to access it.