Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
505 views
in Technique[技术] by (71.8m points)

python - Converting PIL GdkPixbuf

How can I convert PIL Image in pixbuf?. I tried to change many examples but no solution

import array
from gi.repository import GdkPixbuf

def image2pixbuf(self,im):
    arr = array.array('B', im.tostring())
    height, width = im.size
    return GdkPixbuf.Pixbuf.new_from_data(arr, GdkPixbuf.Colorspace.RGB,
                                      True, 8, width, height, width * 4)

Error

TypeError: new_from_data () takes Exactly 9 arguments (7 given)

I use Pygobject https://live.gnome.org/PyGObject

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I have encountered the same problem with Gtk3. GdkPixbuf.PixbufDestroyNotify - NotImplementedError - python gtk3

It seems that there is a bug. I have reported it. https://bugzilla.gnome.org/show_bug.cgi?id=674691

Gtk3 has this bug. But you can still do it in Gtk2.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...