Bases: sage.structure.sage_object.SageObject
Wrapper around a graphics file.
Return a byte string containing the image file.
x.__init__(...) initializes x; see help(type(x)) for signature
Launch external viewer for the graphics file.
Note
Does not actually launch a new process when doctesting.
EXAMPLES:
sage: from sage.structure.graphics_file import GraphicsFile
sage: g = GraphicsFile('/tmp/test.png', 'image/png')
sage: g.launch_viewer()
x.__init__(...) initializes x; see help(type(x)) for signature
Embed in SageNB
This amounts to just placing the file in the cell directory. The notebook will then try to guess what we want with it.
Make the file available under a new filename.
INPUT:
The newly-created filename will be a hardlink if possible. If not, an independent copy is created.
Bases: object
x.__init__(...) initializes x; see help(type(x)) for signature
Return file extension.
INPUT:
OUTPUT:
String containing the usual file extension for that type of file. Excludes os.extsep.
EXAMPLES:
sage: from sage.structure.graphics_file import Mime
sage: Mime.extension('image/png')
'png'
Check that input is known mime type
INPUT:
OUTPUT:
Unicode string of that mime type. A ValueError is raised if input is incorrect / unknown.
EXAMPLES:
sage: from sage.structure.graphics_file import Mime
sage: Mime.validate('image/png')
u'image/png'
sage: Mime.validate('foo/bar')
Traceback (most recent call last):
...
ValueError: unknown mime type
Helper function to construct a graphics file.
INPUT:
OUTPUT:
Return an instance of sage.structure.graphics_file.GraphicsFile encapsulating a suitable image file. Image is one of the preferred_mime_types. If allowed_mime_types is specified, the resulting file format matches one of these.
Alternatively, this function can return None to indicate that textual representation is preferable and/or no graphics with the desired mime type can be generated.