in reply to Re: PerlMagick Gtk2::Gdk::Pixbuf
in thread PerlMagick Gtk2::Gdk::Pixbuf
i would like to share the program that i did. its messy but you can see how i did what zentara showed us.
you can try this out. first change the image files inside the SUB LOAD. run the program and press the LOAD BUTTON. the sub LOAD does the following... open a file using image magick. do something to it then convert it to a blob. then the blob is read by the pixbufloader and is then converted into a pixbuf! yey! then the pixbuf is then converted to a blob. which is then read by image magick!!!! yey!!!!#!/usr/bin/perl -w #image data transfer from imagemagick to pixbuf!!! yey! use Gtk2 '-init'; use Image::Magick; my $pimage; my $pimage2; my $image; my $image2; my $canvas; my $pixbufloader; my $pixbuf; #sub load; my $window = Gtk2::Window->new; $window->signal_connect(destroy=>sub{Gtk2->main_quit;}); $window->set_size_request(1000,600); my $vbox = Gtk2::VBox->new; $window->add($vbox); #my $pixbuf = Gtk2::Gdk::Pixbuf->new(undef); our $image1 = Gtk2::Image->new; my $swin = Gtk2::ScrolledWindow->new; $swin->add_with_viewport($image1); $vbox->pack_start($swin,1,1,0); my $button = Gtk2::Button->new('LOAD'); $button->signal_connect('clicked',\&load); $vbox->pack_start($button,0,1,0); my $button1 = Gtk2::Button->new('VIEW'); $button1->signal_connect('clicked',\&view); $vbox->pack_start($button1,0,1,0); my $button2 = Gtk2::Button->new('IMPLODE'); $button2->signal_connect('clicked',\&implodeimage); $vbox->pack_start($button2,0,1,0); $window->show_all; Gtk2->main; sub load { $image = Image::Magick->new; $image2 = Image::Magick->new; $pimage = Image::Magick->new; $pimage2 = Image::Magick->new; $pimage->Read('frames/rbs5r.png'); $pimage2->Read('pictures/dscf6098.jpg'); $image = $pimage->Clone; $image2 = $pimage2->Clone; $image->Resize( height=>650, width=>(650*$image->Get('width')/$image->Get('height'))); $image2->Resize( height=>650, width=>(650*$image2->Get('width')/$image2->Get('height'))); $canvas = Image::Magick->new; my $w = $image->Get('width'); my $h = $image->Get('height'); my $size = $w . "x" . $h; $canvas->Set(size=>$size); $canvas->ReadImage('xc:white'); $canvas->Set(magick=>'jpeg'); $canvas->Composite( image=>$image2, compose=>'Over'); $canvas->Composite( image=>$image, compose=>'Over'); my $blob = $canvas->ImageToBlob(); $pixbufloader = Gtk2::Gdk::PixbufLoader->new; $pixbufloader->write($blob); $pixbufloader->close; $pixbuf = $pixbufloader->get_pixbuf; $blob = $pixbuf->save_to_buffer('jpeg'); $canvas->BlobToImage($blob); $canvas->Display; #my $preview = $image->Preview('Gamma'); #$preview->Display(); } sub view { #$pixbuf = Gtk2::Gdk::Pixbuf->new_from_file('text.bmp'); $image1->set_from_pixbuf($pixbuf); } sub implodeimage { print "IMPLODE\n"; # print $image2->Blur(20); #$canvas=$image->Clone; $canvas = Image::Magick->new; my $w = $image->Get('width'); my $h = $image->Get('height'); my $size = $w . "x" . $h; $canvas->Set(size=>$size); $canvas->ReadImage('xc:white'); #$image->Crop(geometry=>$size); #$image2->Crop(geometry=>$size); #$image2->Rotate(45); print $canvas->Composite(image=>$image2,compose=>'Over'); print $canvas->Composite(image=>$image,compose=>'Over'); print $canvas->Write('text.bmp'); }
In Section
Seekers of Perl Wisdom