Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Keep It Simple, Stupid
 
PerlMonks  

Re: print-screen without non-core modules ?

by zentara (Archbishop)
on May 26, 2012 at 20:09 UTC ( #972647=note: print w/ replies, xml ) Need Help??


in reply to print-screen without non-core modules ?

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


Comment on Re: print-screen without non-core modules ?
Download Code
Re^2: print-screen without non-core modules ?
by marto (Chancellor) on May 27, 2012 at 10:38 UTC

    "ImageMagick ( installed on most machines )"

    Nitpick: I wouldn't say most machines.

Re^2: print-screen without non-core modules ?
by Anonymous Monk on May 27, 2012 at 15:33 UTC
    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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2014-04-17 04:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (439 votes), past polls