I have a set of jpeg files in a zip archive. I would like to display a member jpeg image in a Tkinter widget.
I'm having trouble creating an Image object. I have tried feeding the output of ZipFile.open() and ZipFile.read() to Image() and PhotoImage(), all of which result in the same error message: "UnsupportedOperation: seek". Documentation for Image.open() states that if a file object is given as the argument, the file object must support the read, seek, and tell methods. Apparently the "file-like object" returned by ZipFile.open() does not qualify.
zfile = zipfile.ZipFile(filename,'r')
...
filelikeobject = zfile.open(membername,'r')
image = Image.open(filelikeobject)
File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1967, in open
fp.seek(0)
UnsupportedOperation: seek
I cannot find any relevant post dealing with zipped jpeg files. I know my zips are well-formed because I can perform this operation, using the same files, in Java and Perl (I am re-writing a large Java application in Python/Tk).
A brute force method would be to extract the member file to disk, and simply call Image(pathname), but I'd rather do everything in memory.
Any help, please.