[SciPy-user] The IO library and image file formats -- compare with with PIL

Zachary Pincus zachary.pincus at yale.edu
Mon Jun 16 15:13:12 EDT 2008


Hi all,

I just heard back from Fredrik. He's supportive of the idea, and made  
some helpful suggestions for how to proceed. It might be simpler than  
I had thought, actually...

Here's his email:

> hi zachary,
>
>> Our general idea is to use the python standard library to handle most
>> compressed data, and use numpy's internal unpacking features to  
>> decode the
>> uncompressed and assembled data streams. Anyhow, it struck me that  
>> the
>> *ImagePlugin.py files from the PIL would be a pretty useful (either
>> unmodified, or more likely, slightly-modified) as the front end of  
>> this IO
>> system, much as they are used in the PIL today.
>
> that definitely makes sense.  to avoid fragmentation, I'd prefer if
> you use unmodified versions (and submit any bug fixes etc upstream).
> the ImagePlugin modules have very few dependencies, on purpose; you
> should be able to create a light-weight "pil emulator" simply by
> plugging in Image, ImageFile, and ImagePalette objects in sys.modules,
> and then use the modules right away.  e.g.
>
>    class ImageEmulator:
>         ... stuff that implements necessary portions of the Image  
> interface ...
>    class ImageFileEmulator:
>         ... etc
>    class ImagePaletteEmulator:
>         ...
>    sys.modules["Image"] = ImageEmulator()
>    sys.modules["ImageFile"] = ImageFileEmulator()
>    sys.modules["ImagePalette"] = ImagePaletteEmulator()
>
>    import PngImagePlugin
>
> see the "open" and "save" code in Image.py to get some ideas on how to
> use the plugins.
>
> (and feel free to mail me if you want further integration ideas)
>
> cheers /F

Best,
Zach



More information about the SciPy-User mailing list