Xiao wrote: > Hi, is it possible to read only a part of an image (png or gif) by PIL? > > For example, an image is 20000x20000 in pixels. Is it possible for > python to read only 100x100 of the picture (not loading the whole > picture) and save the small part to a new png file?
PNG and GIF files are encoded streams, so there's no way to "seek" in the actual image data. For other formats, you can check the "tile" attribute after you've opened the image, but before you've loaded it; if it contains a list of descriptors, or if the type for the descriptors is "raw", you can manipulate the "tile" list so it contains only the part you want to read, and manipulate the "size" accordingly. For an example, see: http://effbot.org/zone/pil-large-images.htm </F> _______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig