[SciPy-User] FreeImage <-> numpy IO wrappers

Zachary Pincus zachary.pincus at yale.edu
Thu May 13 13:43:45 EDT 2010


> I got another question:
> One nice thing about PIL is that I could just throw any image file at
> it and it finds by itself the right format/plugin to load it.
> Does FreeImage have a similar feature ?
> - i.e. determining the image format (not just depending on file name
> extension would be quite important ...

Yeah, it has tools to sniff the type from a file, and also ones to  
determine type based on name alone:
FreeImage_GetFileType and FreeImage_GetFIFFromFilename, respectively.

My wrappers use the former on reading, and the latter for writing, but  
this is easy enough to modify. The return values of the above  
functions are int constants that identify each file format plugin --  
and, from a brief look, it looks like it should be possible to  
implement new format plugins in python, using the ctypes callback tools.

Overall, and to a first approximation, I'm pretty happy with the API  
FreeImage exposes.

Zach



More information about the SciPy-User mailing list