Thanks a lot. I'm really new to python, and haven't coded in over a decade, so please be patient. :-)
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. How can I change it to type Image? Or am I thinking about this in the wrong way? I would like to follow this with something like: picture.thumbnail((128, 128), Image.ANTIALIAS) But obviously I can't do this directly. What am I missing? hdante wrote: > Hi, > > I don't know zipfile by heart, but python official documentation is > always good ( docs.python.org ). You need a loop in the file list like > this: > > for file in zip: > process(file) > > Unfortunatelly, there are too many ways to create a thumbnail from an > image. I'll cite one, using the "python image" external module, that > I've found to be very easy: > > import Image > def process(file): > try: > image = Image.open(file) > image.thumbnail ((128,128), Image.ANTIALIAS) > image.save (file + '.thumb.png') > except: > print 'Skipping file', file > > Links: > http://docs.python.org/lib/lib.html - Python Library Reference > http://www.pythonware.com/library/pil/handbook/image.htm - The Image > Module > > K P S wrote: > > Hi. > > I'm looking for a small script that will take a .zip archive and pull > > the first .jpg from the archive and convert it to a .png. > > > > The reason for this is I want to have tuhmbnails for these archives in > > nautilus under gnome. I would like something similar to the following > > code, which will pull a thumbnail from an openoffice.org (oasis) > > document. What I want is a little more involved, I guess, since I > > don't know the name of the file (for the zip.read command), and I need > > to convert the file from .jpg to .png once I get it. Any help would be > > appreciated. Including a pointer to a web page of a manual with > > examples. :-) > > > > #!/usr/bin/python > > > > import zipfile > > import sys > > import gnomevfs > > > > inURL=gnomevfs.get_local_path_from_uri(sys.argv[1]) > > outURL=sys.argv[2] > > > > zip=zipfile.ZipFile(inURL,mode="r") > > picture=zip.read("Thumbnails/thumbnail.png") > > thumbnail=open(outURL,"w") > > thumbnail.write(picture) > > thumbnail.write("/n") > > zip.close() > > thumbnail.close() -- http://mail.python.org/mailman/listinfo/python-list