[Image-SIG] PIL 1.1.7, windows compilation: problem to save image file
erwan.loaec at cgin.fr
Thu Mar 17 15:22:17 CET 2011
I answer to myself...
I'm using mingw to compile PIL. By default, gcc used msvcrt.dll library,
and the write() function is call through this lib while python.exe
creates the handle through msvcr71.dll.
That's why when I've recreated the handle, both open() and write() call
the same lib (msvcrt.dll), and everything worked.
To solve it, I've change the specs file of gcc by replacing -lmsvcrt
with -lmsvcr71 in the libgcc section, and change write() to _write() in
I hope this could be helpful...
Erwan Loaëc wrote:
> Yes I've try with and without r"XXX" syntax, with absolute, and relative
> path, etc...
> I've forgotten to tell you I'm using ActiveState Python 188.8.131.52
> Rob Cole wrote:
>> I have little clue, except: I've had problems using that r"asdf"
>> syntax. Did
>> you try omitting the 'r' and doubling up on the backslashes?
>> PS - I've been programming in Python now for a total of about a week - so
>> take with salt...
>> -----Original Message-----
>> From: image-sig-bounces+sec=robcole.com at python.org
>> [mailto:image-sig-bounces+sec=robcole.com at python.org] On Behalf Of Erwan
>> Sent: Thursday, March 17, 2011 3:50 AM
>> To: image-sig at python.org
>> Subject: [Image-SIG] PIL 1.1.7, windows compilation: problem to save
>> I've successfully compiled PIL under windows XP 32 bits.
>> When I try to save a JPEG or TIFF file, I obtain the following trace:
>> Traceback (most recent call last):
>> File "D:\testpy\testPIL.py", line 9, in <module>
>> File "C:\Python25\lib\site-packages\PIL\Image.py", line 1439, in save
>> save_handler(self, fp, filename)
>> File "C:\Python25\lib\site-packages\PIL\JpegImagePlugin.py", line
>> 471, in _s
>> ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
>> File "C:\Python25\lib\site-packages\PIL\ImageFile.py", line 499, in
>> s = e.encode_to_file(fh, bufsize)
>> IOError: [Errno 0] Error
>> The problem is the "write(fh, buf, status)" in encode.c which always
>> return "-1". When I create a new handle directly in encode.c
>> fh = open( "mytest.jpg", _O_WRONLY | _O_CREAT | _O_BINARY );
>> The write() works perfectly. So I think the problem should be related
>> to the file descriptor...
>> So, is anyone know the solution for windows ?
>> Note: under linux, everything works perfectly. It really seems to be a
>> "windows" issue.
> Image-SIG maillist - Image-SIG at python.org
More information about the Image-SIG