# How to get the content size (in pixels) of the output in an output cell?

How to get the content size (in pixels, width and height) of the output in an output cell?

Make this button:

Button["Get size",
Print@FrontEndExecute[
FrontEndExportPacket[NotebookSelection[], "BoundingBox"]]]


Then select the output cell and press the button.

It only works when the full output cell is selected (i.e. cell bracket), not just some content within the cell.

You might be able to move the selection programmatically to the output cell, then use this method (without the button).

• Is there a way to make the kernel execute this? – Giovanni F. Dec 7 '14 at 11:18
• @Giovanni I don't understand the question. – Szabolcs Dec 7 '14 at 15:25
• I may be wrong, but from what I saw on the Windows task manager, when executing this command, the main Mathematica process was responsible. It even freezes the front end if there are many calls to FrontEndExecute. I would like if there is a way to let the Kernel do the processing. – Giovanni F. Dec 7 '14 at 17:57
• @Giovanni I understand now. No, there isn't. Notebooks and cells are handled by the front end. Only the front end can compute the size of a cell. Any solution will involve calling the front end in some way. Actually there are many operations that rely on the front end, e.g. exporting any type of graphics. When you run the kernel in a terminal and invoke Export[..., "PNG"]`, a front end process will be silently started up in the background to handle the request. – Szabolcs Dec 7 '14 at 18:00
• @Szabolcs +1 do you know of a list of all the possible second arguments? – Mike Honeychurch Dec 7 '14 at 19:34