in reply to Re^2: Loading PNG in Perl?
in thread Loading PNG in Perl?
GD wouldn't be useful since it only creates images and doesn't read them.
Not so. GD happily loads existing images in the usual formats:
#! perl -slw use strict; use GD; my $img = GD::Image->new( $ARGV[ 0 ] ); my( $w, $h ) = $img->getBounds; print "The image '$ARGV[ 0 ]' is $w x $h pixels."; printf "The color of the pixel in the middle is: [0x%02x:0x%02x:0x%02x +].\n", $img->rgb( $img->getPixel( $w/2, $h/2 ) ); __DATA__ c:\test>junk5 694790clustered.png The image '694790clustered.png' is 800 x 800 pixels. The color of the pixel in the middle is: [0xfc:0xfe:0xfc]. c:\test>junk5 img\worldx2-2.jpg The image 'img\worldx2-2.jpg' is 5400 x 2700 pixels. The color of the pixel in the middle is: [0x04:0x0c:0x11]. c:\test>junk5 img\gradient.gif The image 'img\gradient.gif' is 108 x 108 pixels. The color of the pixel in the middle is: [0xff:0xff:0xff].
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Loading PNG in Perl?
by Xenofur (Monk) on Jul 31, 2008 at 05:07 UTC |