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.


In reply to Timed screencaps by Kickstart

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.