Refresh . The Wizard answer gives a different result than a pixel, but it is only for Windows and destroys the contents of the clipboard. My answer should work on any platform, but it is less accurate: for example. It skips I / O labels. This allows you to set the width of the rasterization.
This problem arose when I was trying to make a preview window for the image downloader (see the end of this answer).
I would like to create a palette button that will load the current selection of the laptop as an image. Before downloading, I would like to show a preview image to reduce the likelihood that something will go wrong before accessing the server.
This is what I have so far (includes only the preview code, not the loader):
button = Button[ "Preview", Module[ {expr = NotebookRead@InputNotebook[]}, If[expr =!= {}, With[{img = Rasterize[expr]}, MessageDialog[ Column[{"Would you like to perform the action?", img}], {"Do it!" :> doIt[img], "Cancel" :> Null} ] ] ] ] ]
In case you are wondering why I used the nested With inside the Module instead of making img modular variable too: this is because by the time doIt[img] local module is calculated, the variables will be cleared, so I need to substitute the rasterized expression directly into the function doIt
This button works (more or less). You can try it by creating graphics in one laptop (for example, Graphics[Circle[]] ), selecting it with one click, then clicking the "Preview" button.
However, if I placed it in the palette using CreatePalette[button] , then rasterization will occur for the width of the palette window, and I will get something like this:

How can I control the width of the rasterization or, more generally, how can I create a preview dialog for a user who avoids this problem?
For further improvement, it would be nice to be able to resize the message box to fit the preview image (and still show the button: the button disappears with WindowSize -> All ).
The answers
Mr. The offer of the master:
button = Button[ "Preview", (FrontEndExecute[ FrontEndToken[FrontEnd`SelectedNotebook[], "CopySpecial", "MGF"]]; MessageDialog[ First@Cases[NotebookGet@ClipboardNotebook[], RasterBox[data_, ___] :> Image[data, "Byte", ColorSpace -> "RGB", Magnification -> 1], Infinity]])] CreatePalette[button]
Problems: It (possibly) only works on Windows, and it destroys the contents of the clipboard.