I often copy-paste things from LatexIt or OmniGraffle into Mathematica notebooks. The results are GraphicsData objects which don't render in the Wolfram Cloud. Is there an easy work-around?

Since bitmaps render properly, perhaps there's some way to automatically convert all GraphicsData objects in the notebook into bitmaps?

Here's example notebook:


How it looks locally

enter image description here

  • $\begingroup$ You should email WRI about this bug $\endgroup$
    – M.R.
    Dec 19 '19 at 6:20
  • $\begingroup$ It's not a bug per se, just a really old Mac behavior. Those programs are emitting PDF to the clipboard instead of a bitmap. And the Mac FE was the only one really capable of handling that particular format. For instance, the Windows FE is not capable of rendering those cells either. $\endgroup$
    – ihojnicki
    Dec 19 '19 at 14:03

I don't know how to convert the given GraphicsData objects into vector graphics, but you can use Rasterize to convert them into bitmaps. Here is a function that does this:

rasterizeGraphicsData[Cell[g:GraphicsData["PDF", __], "Graphics", OptionsPattern[Cell]]] := Module[{size},
    size = OptionValue[Cell, ImageSize];
        BoxData @ ToBoxes @ Rasterize[
            Cell[g, "Graphics"], 
            ImageSize -> size,
            RasterSize -> 5 size

Now, we need to apply the above function on each of the GraphicsData cells. We can do that with the following function:

convertNotebookGraphicsData[nb_] := With[
    {cells = Cells[nb, CellStyle -> "Graphics"]},
    NotebookWrite[#, rasterizeGraphicsData @ NotebookRead[#]]& /@ cells

Use Notebooks to find the notebook object to process and then use convertNotebookGraphicsData[nb] where nb is the NotebookObject corresponding to your notebook.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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