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 encode.c.

I hope this could be helpful...

--
Erwan


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 2.5.1.1

--
Erwan


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...

Rob


-----Original Message-----
From: image-sig-bounces+sec=robcole....@python.org
[mailto:image-sig-bounces+sec=robcole....@python.org] On Behalf Of Erwan
Loaëc
Sent: Thursday, March 17, 2011 3:50 AM
To: image-sig@python.org
Subject: [Image-SIG] PIL 1.1.7, windows compilation: problem to save image
file

Hello,

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>
     im.save(r"D:\testpy\mytest.jpg")
   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
ave
     ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
File "C:\Python25\lib\site-packages\PIL\ImageFile.py", line 499, in _save
     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

example:
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.


Thanks,

_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig
_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to