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


1 Answer 1


Make this button:

Button["Get size", 
   FrontEnd`ExportPacket[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.

Reference: https://mathematica.stackexchange.com/a/1411/12

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

  • $\begingroup$ Is there a way to make the kernel execute this? $\endgroup$ Dec 7, 2014 at 11:18
  • $\begingroup$ @Giovanni I don't understand the question. $\endgroup$
    – Szabolcs
    Dec 7, 2014 at 15:25
  • $\begingroup$ 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. $\endgroup$ Dec 7, 2014 at 17:57
  • $\begingroup$ @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. $\endgroup$
    – Szabolcs
    Dec 7, 2014 at 18:00
  • $\begingroup$ @Szabolcs +1 do you know of a list of all the possible second arguments? $\endgroup$ Dec 7, 2014 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.