vinothje has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Is it possible to install and use Win32::Screenshot in linux environment ? I have the urgent need to capture the web pages.

Replies are listed 'Best First'.
Re: Is Win32::Screenshot work with linux ?
by marto (Cardinal) on Jan 14, 2010 at 17:05 UTC

    Win32:: modules are unsurprisingly for the Microsoft Windows platform. Try Imager::Screenshot search the cpan for similar modules.

      Thanks for suggesting Imager::Screenshot. It has the dependency to Imager cpan module. So i tried installing Imager module, i received the error,

      cp CountColor.pm ../blib/lib/Imager/CountColor.pm /usr/bin/perl /usr/lib/perl5/5.8.8/ExtUtils/xsubpp -typemap /usr/lib/perl5/5.8.8/ExtUtils/typemap CountColor.xs > CountColor.xsc && mv CountColor.xsc CountColor.c

      gcc -c -I.. -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" -fPIC "-I/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE" CountColor.c

      CountColor.c:1: error: bad value (generic) for -mtune= switch make1: *** CountColor.o Error 1

      Could you please help me what i am missing here. Thanks.
        Somewhere in either the package or your system config the parameter -mtune is being set to generic.

        Find and change the setting to native. If native fails, try the correct cpuid for your system (i.e. i386, i686, pentium4, athlon, etc.).

Re: Is Win32::Screenshot work with linux ?
by Corion (Patriarch) on Jan 14, 2010 at 17:40 UTC

    If you want to capture "just" the image of a web page and not the image of a browser displaying a web page, WWW::Mechanize::Firefox should work under Linux and can save the bitmap of a web page.

Re: Is Win32::Screenshot work with linux ?
by zentara (Cardinal) on Jan 15, 2010 at 11:51 UTC
    Try this:
    #!/usr/bin/perl use warnings; use strict; use Image::Magick; use X11::WMCtrl; use Data::Dumper; my $wmctrl = X11::WMCtrl->new; printf("window manager is %s\n", $wmctrl->get_window_manager->{name}); my @windows = $wmctrl->get_windows; my $wid; # x window id my $host; # virtual desktop foreach my $app(@windows){ my $title = $app->{title}; if( $title =~ /Mozilla/i){ print "$title\n"; print Dumper(\$app),"\n\n"; $wid = $app->{id}; $host = $app->{host}; } } $wmctrl->switch($host); #must be on same virtual desktop as the browser #works my $blob = `import -window $wid 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'); exit; # png works too

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku
Re: Is Win32::Screenshot work with linux ?
by jklowden (Novice) on Jan 15, 2010 at 04:58 UTC

    xwd(1)?