[Zope] PIL: can't call same method twice

Chris chris-zopemailing at gmx.de
Sun Mar 6 08:28:35 EST 2005


Hi Dieter,

>   Almost surely, your first call moved the file pointer to
>   the end and the second one does not find content.
> 
>   You can use the "seek" method to reposition the file pointer.

That is, what I thought, too. So I added in PIL.Image.py (Version 1.1.4)
in line 1548 "fp.seek(0)" to "rewind" the file object (see below) to no
avail. So I guess I am not in the right place. But I will dig into the
PIL code soon.
Thanx for pointing me in the right direction.
Regards Chris

# PIL.Image.py
# Opens and identifies the given image file.
def open(fp, mode="r"):
     "Open an image file, without loading the raster data"

     if mode != "r":
         raise ValueError("bad mode")

     if isStringType(fp):
         import __builtin__
         filename = fp
         fp = __builtin__.open(fp, "rb")
     else:
         filename = ""
     fp.seek(0)            # NEW LINE: rewind the object
     prefix = fp.read(16)
     # [...] continue to identify the the image







More information about the Zope mailing list