[Tutor] Fastest way to iterate through a file

elis aeris hunter92383 at gmail.com
Mon Jul 2 01:21:36 CEST 2007

oh i want to bring something up,  there is this one line which i think is
suggesting that there is a way to use this object that the document says
it's a lot faster than getdata and getpixel.


Allocates storage for the image and loads it from the file (or from the
source, for lazy operations). In normal cases, you don't need to call this
method, since the Image class automatically loads an opened image when it is
accessed for the first time.

(New in 1.1.6) In 1.1.6 and later, *load* returns a pixel access object that
can be used to read and modify pixels. The access object behaves like a
2-dimensional array, so you can do:

pix = im.load()
print pix[x, y]
pix[x, y] = value

Access via this object is a lot faster than *getpixel* and *putpixel*.

according to it, this load function is a new addition to 1.1.6, and this
object is different from the rest.

On 7/1/07, Luke Paireepinart <rabidpoobear at gmail.com> wrote:
> elis aeris wrote:
> > I found out that by making a copy of it, it can be load()  ed !
> ImageGrab returns an image instance.
> You can get the pixel data directly using getdata().
> There's no reason to do what you're doing.
> -Luke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070701/08c93c49/attachment.html 

More information about the Tutor mailing list