in reply to Getting pixel color of screen
This isn't a specific answer, but maybe it might give you some idea on which direction to go. Read the documentation for
Imager#!/usr/bin/perl -l use strict; use warnings; use Imager; use Imager::Fill; use Data::Dumper::Concise; my $file = 'Screenshot.png'; my $img = Imager->new(); $img->open( file => $file, type => 'png' ); print "Image information: \n"; print "Width: ", $img->getwidth(); print "Height: ", $img->getheight(); print "Channels: ", $img->getchannels(); print "Bits/Channel: ", $img->bits(); print "Virtual: ", $img->virtual() ? "Yes" : "No"; my $colorcount = $img->getcolorcount; print "Actual number of colors in image: "; print defined($colorcount) ? $colorcount : ">512"; print "Type: ", $img->type(); if ($img->type eq 'direct' ) { print "Modifiable Channels: "; print join " ", map { ($img->getmask() & 1<<$_) ? $_ : () } 0..$img->getchannels(); } my(@rgbanames) = qw( red green blue alpha ); my $mask = $img->getmask(); for (0..$img->getchannels() - 1) { print $rgbanames[$_] if $mask & 1<<$_; } my $color = $img->getpixel(x=>50, y=>70); print Dumper($color);
|
|---|