renegadex has asked for the wisdom of the Perl Monks concerning the following question:

hi! can i use the Gtk2::Gdk::PixbufLoader to load an image from a file? I wanted to create thumbnails for many pictures and this takes up alot of time. So what I need to do is incrementally load those images, at the same time, the user can do other things (click a button) without waiting for the images to load.

Replies are listed 'Best First'.
Re: Incremental Image Loading
by Anonymous Monk on Nov 18, 2008 at 08:18 UTC
Re: Incremental Image Loading
by zentara (Archbishop) on Nov 18, 2008 at 13:26 UTC
    To load a pixbuf from file:
    #get raw image data #my $image_data = `cat image.png`; # easy shell out my $image_data; open (FH,"< image.png"); read( FH, $image_data, -s FH ); close FH; my $pixbuf = do { my $loader = Gtk2::Gdk::PixbufLoader->new(); $loader->write( $image_data ); $loader->close(); $loader->get_pixbuf(); }; #you can then make your thumbnails with the pixbuf methods my $pixbuf_smaller = $pixbuf->scale_simple(50,50,'bilinear'); my $img_smaller = Gtk2::Image->new_from_pixbuf($pixbuf_smaller);

    I'm not really a human, but I play one on earth Remember How Lucky You Are