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

Travis E. Oliphant oliphant@enthought....
Mon Apr 21 13:43:12 CDT 2008

Zachary Pincus wrote:
> numpy.fromstring takes a byte sequence and unpacks it into an array of  
> a specified shape and data type. Most image file formats are just  
> different ways of putting byte sequences on disk and specifying how  
> they were compressed, if at all. Most formats have either no  
> compression, or LZW/Deflate/zlib-style compression, for which there  
> are already python libraries.
> So for example, reading a TIFF file would consist of looking at the  
> header to determine the pixel format, image size, and compression,  
> then rooting around in the file to assemble the relevant bytes, then  
> running that through deflate (most often), and passing the resulting  
> string to numpy.fromstring. Same for PNG, or most anything that's not  
> JPEG. Writing is similar.
> Again, what I'm imagining wouldn't be a full-featured image IO  
> library, but something lightweight with no dependencies outside of  
> numpy, and potentially (if JPEG decoding isn't desired), no C- 
> extensions. (One could conceivably use numpy to do JPEG encoding and  
> decoding, but I've no interest in doing that...)
> This is all just an idea, and I'm not convinced whether it's a great  
> idea. But I just wanted to put the suggestion out there...
I've wanted to have native image readers in SciPy for a long time for a 
lot of reasons (teaching being one of them so I like this approach).  
I'd rather not have a PIL dependency to do such things.   But, that is 
just my point of view.  So, I'm very supportive of this project generally.


More information about the SciPy-user mailing list