Screenshot to memory with ImageMagick
zentara
created: 2006-04-08 10:43:52
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');


Re: Screenshot to memory with ImageMagick
created: 2006-04-11 09:22:51
Why not just use
`import - file_name_based_on_current_date_time.format`
Re^2: Screenshot to memory with ImageMagick
created: 2006-04-11 12:20:05
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
Re^3: Screenshot to memory with ImageMagick
created: 2006-04-12 04:03:08
Aha, now I grok it :-)
I really misunderstood you.

perlmonks.org content © perlmonks.org and arkturuz, zentara

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03