use Image::Magick; my $image = new Image::Magick; $image->Read('foo.png'); my $count; # The number of non-transparent pixels. my $transparent = $image->Get('transparent'); # Index of the transparent colour. my $height = $image->Get('height'); # Image height. my $width = $image->Get('width'); # Image width. for my $x ( 1 .. $height ) { for my $y ( 1 .. $width ) { $count++ if $image->Get("pixel[$x,$y]") != $transparent; } }