Hi, I'm currently working on extending the ctypes based LCMS bindings, and I want to support PIL image types natively inside the doTransform() method on a Transform object.
Anyway, for that task I need to distinguish between different valid object types for the input buffer to decide which action to take. For NumPy arrays that works nicely, but I don't know how to distinguish properly whether I'm dealing with a PIL.Image type object. Below you can find some of the tinkerings of the "obvious" candidates. So far it seems as if only the last one gives me a viable option, but it doesn't strike me as being very pythonic, elegant or even clean in the code. Any suggestions? Guy >>> type(a_numpy_array) <type 'numpy.ndarray'> >>> isinstance(a_numpy_array, numpy.ndarray) True >>> type(a_pil_image) <type 'instance'> >>> isinstance(a_pil_image, instance) [...] NameError: name 'instance' is not defined >>> isinstance(inImage, PIL.Image) [...] TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types >>> isinstance(a_pil_image, PIL.PngImagePlugin.PngImageFile) True >>> str(a_pil_image.__class__).startswith('PIL.') True -- Guy K. Kloss Institute of Information and Mathematical Sciences Te Kura Pūtaiao o Mōhiohio me Pāngarau Room 2.63, Quad Block A Building Massey University, Auckland, Albany Private Bag 102 904, North Shore Mail Centre voice: +64 9 414-0800 ext. 9585 fax: +64 9 441-8181 eMail: g.kl...@massey.ac.nz http://iims.massey.ac.nz _______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig