MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: graphics data in unevaluated cell

  • To: mathgroup at
  • Subject: [mg7170] Re: [mg7134] graphics data in unevaluated cell
  • From: John Fultz <jfultz>
  • Date: Tue, 13 May 1997 01:58:09 -0400 (EDT)
  • Organization: Wolfram Research, Inc.
  • Sender: owner-wri-mathgroup at

seanross at wrote:
> Suppose I have a notebook which generates a graphics image.  I save the
> notebook and open it later.  The graphic image is displayed on the
> screen.  Is there any way I can export it to a file without re-executing
> the code that created it?  HTMLsave is out because it doesn't work in
> 3.0.  I have no applications that read postscript, so that is out.  I
> know that the postscript code is there in the notebook, I just don't
> know how to access it and assign it a symbol name so I can convert it to
> a GIF file and export it.

Display[] can accept a cell expression as well as a graphics
expression.  Here's function that pulls the cell
expression from the notebook and ship it off to Display[],
thus not requiring you to re-evaluate the graphic in the

DisplayNotebookGraphic[filename_String, x_Integer,
				filetype_String] := 
  Display[filename, Cases[NotebookGet[EvaluationNotebook[]],
		Cell[GraphicsData[___], ___], -1][[x]], filetype]

This function must be run in the same notebook that the
graphic is in.  The first argument is the filename you
want to Display[] to.  The second argument indicates which
graphic you want to save (the first, second, third, etc.
graphic in the notebook, from top to bottom).  The third
argument is the file type.  This example takes the
second graphic in the notebook and displays it as a GIF
to C:\temp\test.gif:

DisplayNotebookGraphic["C:\\temp\\test.gif", 2, "GIF"]

Oh, and this function returns exactly what Display[] returns,
which is the entire Cell[] expression, so you'll probably
want to evaluate this with a semicolon after it or tweak
the function definition so it returns nothing.

Hope this helps!

John Fultz
Front End Group
Wolfram Research, Inc.

  • Prev by Date: Re: Plot options broken in Mathematica version 3.01 for Windows
  • Next by Date: Re: GUI for Mma
  • Previous by thread: Printing
  • Next by thread: schroedinger equation