When you use "import" for a screenshot, it requires a filename to write to. This can be a hassle sometimes. Here is a trick I came across to capture the screenshot to memory. I still need to use backticks to run import, and if anyone knows how to do this from PerlMagick, your input would be appreciated.
#!/usr/bin/perl use warnings; use strict; use Image::Magick; my $blob = `import 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(time.'.jpg');

Replies are listed 'Best First'.
Re: Screenshot to memory with ImageMagick
by arkturuz (Curate) on Apr 11, 2006 at 13:22 UTC
    Why not just use
    `import - file_name_based_on_current_date_time.format`
      I think you were missing the point. When you use import, it needs a filename, but what if you want to do something else with the image. You then need to reopen the file and process it. The way I showed avoids the need to reopen the file. It can also be used to send screenshots, without even writing a local copy, like thru email or ftp, or something.

      I'm not really a human, but I play one on earth. flash japh
        Aha, now I grok it :-)
        I really misunderstood you.