Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

print-screen without non-core modules ?

by palkia (Scribe)
on May 26, 2012 at 19:05 UTC ( #972641=perlquestion: print w/ replies, xml ) Need Help??
palkia has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone
I'm looking for a way to "snap" the screen (printscreen) so it (for example) can be manipulated with "Imager",
but without relaying on non-core modules (conversion to exe limitations).
Your thoughts ?
Thx

Update: Resolved
I'm am no longer limited by the "non-core modules" limitation (see this explanation for more details),
and therefore can now solve this problem without relaying on new information.

Regardless of the way this was eventually solved, I'd like to thank everyone for their replays (most appreciated), I have/will learn something from each.
Special thanks to "marto" & "Anonymous Monk", for not giving up on me despite reaching a massive Re^11 depth.
Wouldn't have figured this out without the feedback from you two.

Comment on print-screen without non-core modules ?
Re: print-screen without non-core modules ?
by marto (Chancellor) on May 26, 2012 at 19:17 UTC

    With pp you can create executables with "non-core" modules included.

      Not by my experience.
      Maybe it's possible to tell it to include modules,
      like the cpan page says, but I've never figured out how exactly ^^.
      Thx anyway

      Update:
      I figured it out it works !
      I did needed the -x as proposed in Re^5: print-screen without non-core modules ?
      but as I said before I couldn't figure out how to use this -x line.
      After using -x 2 unidentified strange files were created and than the pl was opened in the very terminal in which the -x was entered (no new terminal was opened).
      After waiting for a long time seeing nothing changes (that is, no exe is created),
      I closed the terminal by hitting the X button on it's window.
      What was actually happening is the 2 files were a mid process part of creating the exe, as was running the pl in that terminal to gather run-time dependencies, otherwise undetectable.
      While the pl was running I needed to use the very part(s) of the program the experienced problems in the exe version created without the -x line.
      Once that as done, the dependencies were considered.
      Than the pl needed to be properly closed (by internal process, that is without closing the terminal),
      only than the 2 files (along with the run-time dependencies) merged into a beautiful fully functioning exe file.
      Just to bad the Cpan page of "pp" doesn't explain this process as usage instructions.

        What part of the documentation didn't make sense? What did you try which didn't work as you expected?

Re: print-screen without non-core modules ?
by zentara (Archbishop) on May 26, 2012 at 20:09 UTC
    You will need to get over your aversion to non-core modules.

    The utility "import" from ImageMagick ( installed on most machines ) can capture the root window to a "blob", which can be manipulated by Imager or ImageMagick.

    #!/usr/bin/perl use warnings; use strict; use Image::Magick; my $blob = `import -window root jpg:-`; #my $blob = `import -`; #postscript produced #print "$blob\n"; # now $blob is in memory and you can do what you # want with it. my $output = Image::Magick->new(magick=>'jpg'); $output->BlobToImage( $blob ); #$output->Resize(geometry=>'160x120'); $output->Write( $0.'.jpg'); # png works too # or use Imager use Imager; # Convert image my $img = Imager->new; $img->read(data=>$blob, type=>'jpeg') or die "Cannot read: ", $img->errstr; #See perldoc Imager::Transformations my $rot20 = $img->rotate(degrees=>20); $rot20->write(file=>"$0-rot20.jpg", type=>'jpeg') or die "Cannot write: ",$rot20->errstr;

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh

      "ImageMagick ( installed on most machines )"

      Nitpick: I wouldn't say most machines.

      Hi
      where can I find this for ActiveState Perl (Win)?
        The ImageMagick binary, which contains the "import" utility, is at IM binary releases.

        I'm not sure where the Window's perl module for ImageMagick can be found nowadays. Just so you are clear, there is a ImageMagick set of C libs and utilities ( cited above), and there is a PerlMagick Perl module. They are different entities.


        I'm not really a human, but I play one on earth.
        Old Perl Programmer Haiku ................... flash japh
Re: print-screen without non-core modules ?
by Corion (Pope) on May 27, 2012 at 07:26 UTC
Re: print-screen without non-core modules ?
by BrowserUk (Pope) on May 28, 2012 at 17:38 UTC

    See Windows screengrab with GD;


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

Re: print-screen without non-core modules ?
by zentara (Archbishop) on Jun 01, 2012 at 09:31 UTC
    Here is another good one using Gtk2
    #!/usr/bin/perl use warnings; use strict; use Gtk2 -init; my $s = Gtk2::Gdk::Screen->get_default; my $w = $s->get_root_window; my $p = Gtk2::Gdk::Pixbuf->get_from_drawable ( $w, undef, 0, 0, 0, 0, $s->get_width, $s->get_height); $p->save ($0.'.jpg', 'jpeg', quality => 10);

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://972641]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2013-05-20 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best material for plates (tableware) is:









    Results (409 votes), past polls