Re: Convert a pixbuf to a pil Image ?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Convert a pixbuf to a pil Image ?

Danny Milosavljevic
Hi,

Am Donnerstag, den 26.05.2005, 23:12 +0200 schrieb manatlan:
> thanks a lot .. christian
> it works well for me ... i was easy ;-(
>
> import gtk
> import Image
>
> def pixbuf2Image(pb):
>     width,height = pb.get_width(),pb.get_height()
>     return Image.fromstring("RGB",(width,height),pb.get_pixels() )

hm, you dont need to specify rowstride ? Strange... I wonder if it uses
its crystal ball :)

>
> pb = gtk.gdk.pixbuf_new_from_file( "p20050424_160333.jpg" )
> im = pixbuf2Image(pb)
> im.save("welldone.jpg", "JPEG",quality=80)

cheers,
   Danny

>
>
> On 5/25/05, Christian Robottom Reis <[hidden email]> wrote:
> > On Wed, May 25, 2005 at 11:19:34PM +0200, manatlan wrote:
> > > it's easy to convert a PIL Image to a Pixbuf, like this :
> > > http://slugathon.python-hosting.com/changeset/205
> > >
> > > but is it possible to Convert a pixbuf to a pil Image ?
> >
> > The tips I managed to wrestle from Johan were:
> >
> >     <jdahlin> pixbuf.get_pixels()
> >     <jdahlin> PIL.Image.frombuffer()
> >
> > If you manage, could you post a very small testcase so I can add that to
> > the FAQ? Thanks.
> >
> > Take care,
> > --
> > Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 3376 0125
> >
> _______________________________________________
> pygtk mailing list   [hidden email]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
>
--
www.keyserver.net key id A334AEA6


_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

signature.asc (196 bytes) Download Attachment