Image.frombuffer and warning

N

News123

Hi,

I am using the PIL function from_buffer in python 2.6.4

I am having the line
im2 = Image.frombuffer('L',(wx,wy),buf)


I receive the warning:
./pytest.py:63: RuntimeWarning: the frombuffer defaults may change in
a future release; for portability, change the call to read:
frombuffer(mode, size, data, 'raw', mode, 0, 1)
im2 = Image.frombuffer('L',(wx,wy),buf)


Naively I assumed, that changing my code to


im2 = Image.frombuffer('L',(wx,wy),buf,'raw','L',0,1)


should fix the issue:

However I receive exactly the same error as before.

What am I doing wrong?


thanks a lot in advance and bye


N
 
P

Peter Otten

News123 said:
I am using the PIL function from_buffer in python 2.6.4

I am having the line
im2 = Image.frombuffer('L',(wx,wy),buf)


I receive the warning:
a future release; for portability, change the call to read:


Naively I assumed, that changing my code to


im2 = Image.frombuffer('L',(wx,wy),buf,'raw','L',0,1)


should fix the issue:

However I receive exactly the same error as before.

What am I doing wrong?

I cannot reproduce the problem:

$ cat frombuffer.py
import sys
import Image
wx = 3
wy = 2
buf = "a"*wx*wy
if "--fixed" in sys.argv:
Image.frombuffer("L", (wx, wy), buf, "raw", "L", 0, 1)
else:
Image.frombuffer("L", (wx, wy), buf)

$ python frombuffer.py
frombuffer.py:9: RuntimeWarning: the frombuffer defaults may change in a
future release; for portability, change the call to read:
frombuffer(mode, size, data, 'raw', mode, 0, 1)
Image.frombuffer("L", (wx, wy), buf)
$ python frombuffer.py --fixed
$ python -c"import Image; print Image.VERSION"
1.1.6
$ python -V
Python 2.6.4

Peter
 
N

News123

Hi Peter,

Peter said:
News123 wrote:
I cannot reproduce the problem:

$ cat frombuffer.py
import sys
import Image
wx = 3
wy = 2
buf = "a"*wx*wy
if "--fixed" in sys.argv:
Image.frombuffer("L", (wx, wy), buf, "raw", "L", 0, 1)
else:
Image.frombuffer("L", (wx, wy), buf)

$ python frombuffer.py
frombuffer.py:9: RuntimeWarning: the frombuffer defaults may change in a
future release; for portability, change the call to read:
frombuffer(mode, size, data, 'raw', mode, 0, 1)
Image.frombuffer("L", (wx, wy), buf)
$ python frombuffer.py --fixed
$ python -c"import Image; print Image.VERSION"
1.1.6
$ python -V
Python 2.6.4

Peter

You're absolutely right. It was my error.
I shouldn't do any lat night coding :-(.

I fixed one frombuffer() statement, but overlooked a second one in my
code :-(


Apologies


N
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top