[Image-SIG] PIL with JPEG support on Windows: Error Writing JPEG file

Fredrik Lundh fredrik at pythonware.com
Wed Mar 25 16:38:34 CET 2009


2009/3/25 Bryan Jeal <bryan at hideawaystudios.com>:
> Here is an update:
>
> 1.
> I removed Python and PIL from the system and reinstalled them (for PIL I
> used PIL-1.1.6.win32-py2.5.exe); however, it isn't working correctly...

I'm not sure why you think you need to open the output file yourself,
but if you do, you need to tell Python that it's a binary file.
Changing

    tmpFile = open('C:/temp/temp_win.jpg', 'w')

to

    tmpFile = open('C:/temp/temp_win.jpg', 'wb')

or, easier, changing the save call to

    im.save("c/temp/temp_win.jpg", 'JPEG', quality=90)

will fix this.

</F>


More information about the Image-SIG mailing list