Can I get the as-rendered width of the legend box in pixels?

I was also wondering if this was possible, see last sentence in this post:
Is it possible to set manually the width of the plotting area, letting the legend expand right at will?