How to cap ImageSize at the notebook width?
I'm not sure it is what you want, but have you tried
CurrentValue[EvaluationNotebook[], "GraphicsBoxOptionsImageSizeRaw"] = 500
This instantly resizes all graphics inside a notebook to 500 pixels as long as your notebook window is large enough.
As @Kuba pointed out, this can be used as option for Graphics
Graphics[{Circle[]},
ImageSize -> Automatic,
BaseStyle -> "GraphicsBoxOptionsImageSizeRaw" -> 200]
Another possibility due to @CarlWoll is
Graphics[Circle[], ImageSizeRaw -> {500}]
How I found it
Initially, I was sure I had seen an option for that so I looked through
AbsoluteOptions[$Notebooks]
It turned out that what I had in mind was the option "DefaultNewGraphics"
which is something else. My next thought was that it is very likely that this is exposed through CurrentValue
. We have a question about all possible current values which led me, only the devil knows how, to this pastebin. A quick scan revealed the "GraphicsBoxOptionsImageSizeRaw"
setting.
This is not a general solution but an improvement for Dynamic
approach. It will run completely FrontEnd side:
Graphics[Circle[]
, ImageSize -> Dynamic @ If[
FEPrivate`Less[CurrentValue[{WindowSize, 1}] - 100, 500]
, Full
, 500
, 500
]
]
-100
is unfortuantely manual, will try to get margins+toolbars width somehow.