Skip to content

tiff file handle is closed too early #2049

Description

@db4

Suppose I have a TIFF file with 2 pages. I do

tiff = Image.open('file.tif')
tiff.seek(0)
tiff.load()
tiff.seek(1)
tiff.load()

this somehow triggers the tiff handle closing:

# TiffImagePlugin.py, line 1077
        # libtiff closed the fp in a, we need to close self.fp, if possible
        if hasattr(self.fp, 'close'):
            if not self.__next:
                self.fp.close()

and subsequent

tiff.seek(0)

will fail with ValueError: seek of closed file
I tried to fix this in 30dc185 but this was not enough. So I hope someone familiar with the code will fix it correctly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions