in reply to Accessing the pen values of the pixels of a GIF?

I'm not sure exactly what you mean by "pen"? But assuming you mean palette index, then this will get you started.

It takes an image name as it's command line argument and outputs a table showing the palette indexes, the rgb values at those indexes and the count of pixels using that index. It will be easy to modify to just display the index/rgb of a particular pixel:

#! perl -slw use strict; use GD; my $img = GD::Image->new( $ARGV[0] ) or die $!; my %palette; my( $x, $y ) = $img->getBounds; for my $yi ( 0 .. $y ) { ++$palette{ $img->getPixel( $_, $yi ) } for 0 .. $x; } for my $i ( sort{ $a <=> $b } keys %palette ) { printf "index:%3d (%02x:%02x:%02x) n:%d\n", $i, $img->rgb( $i ), $palette{ $i }; } __END__ C:\test>imgInspect.pl v3d_usb_perf.gif index: 0 (ff:ff:ff) n:274410 index: 1 (00:00:7f) n:4909 index: 2 (7f:7f:7f) n:80 index: 3 (00:00:ff) n:14025 index: 5 (3f:3f:3f) n:2390 index: 6 (00:ff:00) n:12507

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy

Replies are listed 'Best First'.
Re^2: Accessing the pen values of the pixels of a GIF?
by Anonymous Monk on Nov 08, 2010 at 08:43 UTC
    Finally, a graphics system that lets you at the values in the GIF, rather than pretranslating them back to colours. Thanks for pointing me in the right direction. However, I thought it better to go with this:
    #! perl -slw use strict; use GD; my $img = GD::Image->new( $ARGV[0] ) or die $!; my %palette; my $total= 0; my( $x, $y ) = $img->getBounds; for my $yi ( 0 .. $y-1 ) { ++$palette{ $img->getPixel( $_, $yi ) } for 0 .. $x-1; } for my $i ( sort{ $a <=> $b } keys %palette ) { $total += $palette{ $i }; printf "index:%3d (%02x:%02x:%02x) n:%d\n", $i, $img->rgb( $i ), $palette{ $i }; } print( " $x * $y = ", $x*$y, " =?= $total\n");

    M.

      Good catch on my bounds error. ++