Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
i would like to share the program that i did. its messy but you can see how i did what zentara showed us.
#!/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'); }
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!!!!

In reply to Re^2: PerlMagick Gtk2::Gdk::Pixbuf by renegadex
in thread PerlMagick Gtk2::Gdk::Pixbuf by renegadex

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-23 19:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found