#12827: Expand Animation class to accept more graphics types
-----------------------------------------+----------------------------------
Reporter: niles | Owner: jason, was
Type: enhancement | Status: new
Priority: major | Milestone: sage-5.0
Component: graphics | Resolution:
Keywords: animate, graphics, 3D | Work issues: docstrings, testing,
think about img protocol
Report Upstream: N/A | Reviewers:
Authors: Niles Johnson | Merged in:
Dependencies: | Stopgaps:
-----------------------------------------+----------------------------------
Comment (by niles):
Replying to [comment:3 nbruin]:
> Without reading any documentation, I would expect G.img() to return an
"image object"
Hmm, yes I see your point. Thanks for the tip about PIL -- that package
does seem to provide a pretty good `Image` object, which is created by
reading an image. So one might do something like the following:
{{{
def img(self, filename, *args, **kwds):
self.save(filename=filename, *args, **kwds)
from PIL import Image
im = Image.open(filename)
return im
}}}
Maybe this is the wrong way to go about it though, since the `save()` and
`show()` methods of the resulting `Image` object would re-save the image
to a file, wasting a lot of time. `Image` also has the capability to read
an image from a stream or a buffer, but I don't know how to create such
things from Sage's graphics objects.
On the other hand, the current `show()` method of Sage's graphics objects
saves the image to a file before showing it, so this implementation would
be following that precedent.
A more rudimentary compromise might be to have a method which saves the
image and returns the system path to the image:
{{{
def img(self, filename, *args, **kwds):
self.save(filename=filename, *args, **kwds)
return filename
}}}
At this stage, I've given three different possible `img` methods, and I
can see now how each one establishes a different protocol. Since this
ticket is probably not the right place to try to establish a protocol, I
think I'll try to use a different name. I'm really having a hard time
warming up to the term "bitmap" though. Wikipedia explains to me that it
is essentially correct, although the image types we would use by default,
like JPG, PNG, TIFF, are ''compressed'' bitmap images. What do you think
of `save_image` instead?
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12827#comment:4>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.