Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac #21840: Options dismissed when saving a Graphics3d object to a P…
Browse files Browse the repository at this point in the history
…NG file

When saving a 3D object to a PNG file, the options passed to `save` are
not taken into account:

{{{
sage: g = sphere()
sage: g.save("sphere.png", aspect_ratio=[1, 1, 0.5], viewer='tachyon')
}}}
None of the above options is effective: the output file is generated
with Jmol (instead of Tachyon), with an aspect ratio of [1,1,1].
Actually, the options are not passed to `save_image` (which is invoked
by `save`):
{{{
sage: g.save_image("sphere.png", aspect_ratio=[1, 1, 0.5],
viewer='tachyon')
}}}
produces the expected result.

This ticket corrects this and updates the documentation of
`Graphics3d.save`

URL: https://trac.sagemath.org/21840
Reported by: egourgoulhon
Ticket author(s): Eric Gourgoulhon
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager authored and vbraun committed Nov 9, 2016
2 parents 832b0e5 + ad518a7 commit 91f9af6
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/sage/plot/plot3d/base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1456,7 +1456,7 @@ end_scene""" % (render_params.antialiasing,
filename. This can be either:
- an image file (of type: PNG, BMP, GIF, PPM, or TIFF) rendered
using Tachyon,
using Jmol (default) or Tachyon,
- a Sage object file (of type ``.sobj``) that you can load back later
(a pickle),
Expand All @@ -1471,12 +1471,12 @@ end_scene""" % (render_params.antialiasing,
- ``filename`` -- string. Where to save the image or object.
- ``**kwds`` -- When specifying an image file to be rendered by Tachyon,
any of the viewing options accepted by show() are valid as keyword
arguments to this function and they will behave in the same way.
Accepted keywords include: ``viewer``, ``verbosity``, ``figsize``,
``aspect_ratio``, ``frame_aspect_ratio``, ``zoom``, ``frame``, and
``axes``. Default values are provided.
- ``**kwds`` -- When specifying an image file to be rendered by Tachyon
or Jmol, any of the viewing options accepted by show() are valid as
keyword arguments to this function and they will behave in the same
way. Accepted keywords include: ``viewer``, ``verbosity``,
``figsize``, ``aspect_ratio``, ``frame_aspect_ratio``, ``zoom``,
``frame``, and ``axes``. Default values are provided.
EXAMPLES::
Expand All @@ -1489,15 +1489,15 @@ end_scene""" % (render_params.antialiasing,
sage: G.save(f, zoom=2, figsize=[5, 10])
But some extra parameters don't make sense (like ``viewer``, since
rendering is done using Tachyon only). They will be ignored::
Using Tachyon instead of the default viewer (Jmol) to create the
image::
sage: G.save(f, viewer='jmol') # Looks the same
sage: G.save(f, viewer='tachyon')
Since Tachyon only outputs PNG images, PIL will be used to convert to
alternate formats::
sage: cube().save(tmp_filename(ext='.gif'))
sage: cube().save(tmp_filename(ext='.gif'), viewer='tachyon')
Here is how to save in one of the data formats::
Expand All @@ -1512,7 +1512,7 @@ end_scene""" % (render_params.antialiasing,
SageObject.save(self, filename)
elif ext in ['.bmp', '.png', '.gif', '.ppm', '.tiff', '.tif',
'.jpg', '.jpeg']:
self.save_image(filename)
self.save_image(filename, **kwds)
elif filename.endswith('.spt.zip'):
scene = self._rich_repr_jmol(**kwds)
scene.jmol.save(filename)
Expand Down

0 comments on commit 91f9af6

Please sign in to comment.