[Image-SIG] PIL 1.1.7 Image sequences
fredrik at pythonware.com
Sun May 31 15:42:56 CEST 2009
On Sat, May 30, 2009 at 3:18 PM, Karsten Hiddemann
<karsten.hiddemann at mathematik.uni-dortmund.de> wrote:
> I'd like to create a plugin for some image container / sequences format
> with varying image frame dimensions. An example would be DDS (DirectX8
> texture) files, or the already included Mac OS X icns file format. Has
> PIL 1.1.7 improved support for this or is it already easily achievable
> with the current stable PIL version as well? I'd like to see a code
> examples how such a plugin would look like if possible.
There's no formally standardized support for this, beyond the current
seek/tell API. Some guidelines:
- when opening an image, seek to the "best" image (for some suitable
definition of best)
- to support seeking, implement the "seek" and "tell" methods. seek
should accept indexes from 0 to N (where N doesn't have to be known in
- im.seek(im.tell()+1) should be supported if at all possible.
- treating seek index 0 as the "best" image is nice, but not required.
- the seek method should modify the image in place, usually by setting
at least "mode", "size" and the "tile" descriptor (which is used for
lazy loading of the actual raster data). see e.g. the Dcx, Tiff, and
Im loaders for examples.
- there's no standard API to seek to an image that matches a given
constraint (e.g. most colors, best resolution), so you're free to
invent your own extension API here (e.g. im.seek(im.find(...)))
however, if the image contains multiple versions of the exactly the
same data, you can implement the "draft" method and have it seek to
the right frame.
More information about the Image-SIG