# Graphics dimensions (imprecise PlotRange function)

Is there a function that gives you dimensions of Graphics? I mean x and y dimensions of rectangular region that the content of Graphics would fit into.

Graphics[{Table[
Circle[RandomReal[{-10, 10}, 2], RandomReal[{0, 10}, 2],
RandomReal[{0, 2 π}, 2]], {n, 100}]}] Update:

PlotRange is of no use since it is far from being precise.

v = Table[
Circle[RandomReal[{-10, 10}, 2], RandomReal[{0, 10}, 2],
RandomReal[{0, 2 π}, 2]], {n, 100}];
Graphics[{v}];
Graphics[{v, {Transparent, EdgeForm[Red],
Rectangle @@ Transpose[PlotRange[%]]}}] Also BoundingRegionis of no use for the same reason - being imprecise.

• It does not work for any Graphics. It is not that it does not work only in specific situations. – azerbajdzan Oct 13 '20 at 9:19
• You could e.g. try: Rasteriz[ graphics , "RasterSize"] – Daniel Huber Oct 13 '20 at 10:06

## 1 Answer

You can use the ResourceFunction "GraphicsInformation" for this purpose:

SeedRandom;
g = Graphics[{
Table[
Circle[RandomReal[{-10,10},2],RandomReal[{0,10},2],RandomReal[{0,2 π},2]],
{n, 100}
] Using the "GraphicsInformation" resource function:

pr = Lookup[ResourceFunction["GraphicsInformation"][g], "PlotRange"]


{{-17.8295, 17.0196}, {-19.7501, 19.9222}}

Check:

Show[
g,
Epilog -> {
EdgeForm[Red],
FaceForm[None],
Rectangle[{pr[[1,1]], pr[[2,1]]}, {pr[[1,2]], pr[[2,2]]}]
}
] "GraphicsInformation" also returns other pieces of useful information:

Keys @ ResourceFunction["GraphicsInformation"][g]


{"ImagePadding", "ImageSize", "PlotRangeSize", "ImagePaddingSize",
"PlotRange", "BasePlotRange"}