http://www.perlmonks.org?node_id=972647


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

Replies are listed 'Best First'.
Re^2: print-screen without non-core modules ?
by marto (Cardinal) 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