Simple script to make .png thumbnails from .zip archive...
Fredrik Lundh
fredrik at pythonware.com
Mon Jun 19 06:56:43 EDT 2006
K P S wrote:
> I'm able to read a .jpg from a .zip archive, but can't seem to
> manipulate it. If I do this:
>
> zip=zipfile.ZipFile(inURL,mode="r")
> picture=zip.read("00.jpg")
>
> I get the image, but it is of "type" ZipFile.
string, more likely (zip is a ZipFile object, picture is a string of
bytes). PIL expects a file name or a file object, so you need to use
the StringIO adapter:
picture = zip.read(name) # returns a string
file = StringIO.StringIO(picture) # wrap string in file-like object
image = Image.open(file) # create image object from file-like object
</F>
More information about the Python-list
mailing list