# How to obtain the ImageSize?

I want to obtain the ImageSize of an output in printer's points, which is the standard unit of measurement of ImagePadding, ImageMargins etc.

For example I have a Plot

plot = ListPlot[{}, ImageSize -> 500, AspectRatio -> 2]


This plot will have an ImageSize of 500. If I use

N[ImageDimensions[plot]]


It gives {834., 1665.}, which is the "pixel dimension". I could now define a factor (in this case 1/333.6) to get the ImageSize in printers points, but this is not reliable, since the "pixel dimension" does not go linear with the ImageSize. Is there a better way to obtain the ImageSize in printers points for both x and y directions?

• Options[plot, ImageSize] results in {ImageSize -> 500} Feb 23, 2023 at 16:44
• @DanielHuber AboluteOptions[plot, ImageSize] would be better. Feb 23, 2023 at 18:12
• Options[plot, ImageSize] only gives the option, which was chosen in the command and does not help determining the ImageSize in the y-direction. Feb 24, 2023 at 9:52

This is not the best answer, but perhaps a good starting point.

There exists a resource function developed by @Carl Woll that is called GraphicsInformation

You can do

"ImageSize" /. ResourceFunction["GraphicsInformation"]@plot


and you will get a result with a mismatch.

However, I claim that the missing factor between the first number and the value of ImageSize is always $$\tfrac{4}{5}$$

I have checked the following examples

plot1 = ListPlot[{}, ImageSize -> 300, AspectRatio -> 1];
plot2 = ListPlot[{}, ImageSize -> 300, AspectRatio -> 2];
plot3 = ListPlot[{}, ImageSize -> 300, AspectRatio -> 3];
plot4 = ListPlot[{}, ImageSize -> 300, AspectRatio -> GoldenRatio];
plot5 = ListPlot[{}, ImageSize -> 300, AspectRatio -> 1/GoldenRatio];
"ImageSize" /. ResourceFunction["GraphicsInformation"]@plot1
"ImageSize" /. ResourceFunction["GraphicsInformation"]@plot2
"ImageSize" /. ResourceFunction["GraphicsInformation"]@plot3
"ImageSize" /. ResourceFunction["GraphicsInformation"]@plot4
"ImageSize" /. ResourceFunction["GraphicsInformation"]@plot5


Then

plot1 = ListPlot[{}, ImageSize -> 400, AspectRatio -> 1];
plot2 = ListPlot[{}, ImageSize -> 400, AspectRatio -> 2];
plot3 = ListPlot[{}, ImageSize -> 400, AspectRatio -> 3];
plot4 = ListPlot[{}, ImageSize -> 400, AspectRatio -> GoldenRatio];
plot5 = ListPlot[{}, ImageSize -> 400, AspectRatio -> 1/GoldenRatio];
"ImageSize" /. ResourceFunction["GraphicsInformation"]@plot1
"ImageSize" /. ResourceFunction["GraphicsInformation"]@plot2
"ImageSize" /. ResourceFunction["GraphicsInformation"]@plot3
"ImageSize" /. ResourceFunction["GraphicsInformation"]@plot4
"ImageSize" /. ResourceFunction["GraphicsInformation"]@plot5


And finally,

plot1 = ListPlot[{}, ImageSize -> 55, AspectRatio -> 1];
plot2 = ListPlot[{}, ImageSize -> 55, AspectRatio -> 2];
plot3 = ListPlot[{}, ImageSize -> 55, AspectRatio -> 3];
plot4 = ListPlot[{}, ImageSize -> 55, AspectRatio -> GoldenRatio];
plot5 = ListPlot[{}, ImageSize -> 55, AspectRatio -> 1/GoldenRatio];
"ImageSize" /. ResourceFunction["GraphicsInformation"]@plot1
"ImageSize" /. ResourceFunction["GraphicsInformation"]@plot2
"ImageSize" /. ResourceFunction["GraphicsInformation"]@plot3
"ImageSize" /. ResourceFunction["GraphicsInformation"]@plot4
"ImageSize" /. ResourceFunction["GraphicsInformation"]@plot5


The above is not rigorous, but perhaps is pointing towards the right direction. Of course, more checks are needed. A robust explanation would be fantastic really. Finally, to the author of the O.P, if you are unhappy with the answer let me know and I will delete it.

• I don't know what you mean. In my case the result of the ResourceFunction is exactly the ImageSize in printers points I needed. There is no mismatch. Thank you very much! Feb 24, 2023 at 9:56
• @mathematica_guy glad to hear that. it's possible that I miseread something in the question. anyway, good to know that this method works fine :-)
– bmf
Feb 24, 2023 at 10:05