Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Timed screencaps

by Kickstart (Pilgrim)
on Sep 20, 2001 at 09:05 UTC ( [id://113531]=CUFP: print w/replies, xml ) Need Help??

Nothing ultra fancy here, but maybe some of you will find a use. Basically, I needed a script that would do timed captures of some Java applets in Netscape. It's more an interface to the 'import' utility of ImageMagick, but what the hey. After these images are created it's easy enough to use 'convert' on the command line to create an animated gif for use elsewhere.

An example usage: ./timed_import 320 240 30 200 1 30
...takes 30 caps at 1 second delay between each. The caps will be 320x240 and will be offset 30(x) and 200(y) from the top left of the screen.

Obviously, this is a Unix only solution and requires ImageMagick be installed.

Kickstart

#!/usr/local/bin/perl -w use strict; my $put_dir = '/home/user/screencaps/'; my ($topleftx, $toplefty, $width, $height, $delay, $num) = @ARGV; my $captime = time(); my $count; my $leave = 0; # gonna be like this: # import -window root -crop 300x200+200+200 foo.gif unless ($topleftx && $toplefty && $width && $height && $delay && $num) + { $leave = 1; print <<'EOUSAGE' Usage: ./timed_import <width> <height> <offset x> <offset y> <delay in seconds> <number of caps to take> Filenames will be a UNIX timestamp set at script run followed by the n +umber of the capture (ie. 1000959520-3.jpg) EOUSAGE } exit if $leave == 1; my $cropvalues = $topleftx . 'x' . $toplefty . '+' . $width . '+' . $h +eight; $count = 1; while ($count <= $num) { my $filename = $captime . "-$count" . '.jpg'; my $cmd = 'import -window root -crop ' . $cropvalues . ' ' . $ +put_dir . $filename; my $devnull = `$cmd`; sleep($delay); $count++; }

Edit kudra, 2001-09-21 Replaced pre with code

Update Kickstart, 2001-10-29 Use 'convert' instead of 'animate' to make animated gifs of the screencaps with the ImageMagick utilities.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://113531]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-23 14:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found