[Image-SIG] Example Code for Displaying Pictures--I'm Stumped

Fredrik Lundh fredrik at pythonware.com
Thu Nov 26 09:37:04 CET 2009

On Thu, Nov 26, 2009 at 3:05 AM, Bill Janssen <janssen at parc.com> wrote:

>        # Note: Don't try and use frombuffer(..); different versions of
>        # PIL will orient the image differently.
>        pil_image = Image.fromstring(
>            format, (image.width, image.height), image.get_data(format, pitch))

frombuffer interprets the default decoder settings differently from
fromstring; this is being fixed long-term, but as mentioned in the
documentation, you can do it portably by spelling out the decoder

    im = Image.frombuffer(mode, size, data, "raw", mode, 0, 1)

(1.1.7 will also warn you if you call it without the last four arguments).


More information about the Image-SIG mailing list