I'm not sure you do.
The file on your computer hard disk is 7mb. That doesn't change at all. When opened the 23 megs is in RAM, never on your HD, and I cannot imagine why you need that information. When opened the Jpeg gives you the full image.
I also learned that the numbers - eg: 2480x3650 pixels - in the image's info panel will tell me the file size; that is, there's a formula to convert the pixel numbers into megabytes.
Are you sure about that because I certainly am not.
The pixel dimensions of an image are the length by breadth. Multiplying them by each other will give you the megapixel size of the image. That has no simple relationship to the megabytes. The assumption behind that is that a:all pickles are the same, and they're not and b: Jpeg compression is constant, and it's not.
So, taking a simple case of two images 6000 x 4000 pixels. That's a 24 megapixel image.
Now, suppose image A is of a blank white wall and image b is of a complex landscape. They will not have the same megabyte size.
Further, Jpeg compression varies according to the app used to create the Jpeg and the settings available on the app. That's wholly unpredictable. You have no idea the Jpeg ratios used on your camera, for instance, So, any one of those images shot on a Canon might have a 5mb file size, shot on a Sony or Nikon it could be 4mb or 6.
But mostly, I think you're wasting your time. When you open Jpeg you see the full image.