use strict;
use warnings;
use feature 'say';
use GD;
use Digest::MD5 'md5_hex';
say $^V;
say $GD::VERSION;
say eval { GD::VERSION_STRING() } || '-';
GD::Image-> trueColor( 1 );
my $fn = 'CoventryCathedral.png';
my $i = GD::Image-> new( $fn );
use constant W => 100;
my $j = GD::Image-> new( W, W );
$j-> copyResampled( $i,
0, 0,
( $i-> width - $i-> height ) * .5, 0,
W, W,
$i-> height, $i-> height );
say eval { md5_hex( $j-> gd )} || '-';
say md5_hex( my_gd( $j ));
sub my_gd { # same as gd() for truecolor images
my $gd = shift;
my ( $w, $h ) = $gd-> getBounds;
my $s = '';
for my $y ( 0 .. $h - 1 ) {
for my $x ( 0 .. $w - 1 ) {
$s .= pack 'L>', $gd-> getPixel( $x, $y );
}
}
return "\xff\xfe" .
( pack 'S>2', $w, $h ) .
"\1\xff\xff\xff\xff" .
$s
}
__END__
v5.38.0
2.78
2.3.2
-
c97e63fc792ef75b5ff49c078046321e
v5.32.1
2.76
2.2.5
c97e63fc792ef75b5ff49c078046321e
c97e63fc792ef75b5ff49c078046321e
v5.24.3
2.66
2.1.1
adc191aea66fdf99fd74aaeb20b34e5e
adc191aea66fdf99fd74aaeb20b34e5e
####
use strict;
use warnings;
use feature 'say';
use GD;
say $^V;
say $GD::VERSION;
say eval { GD::VERSION_STRING() } || '-';
GD::Image-> trueColor( 1 );
my $i = GD::Image-> new( 8, 8 );
$i-> filledRectangle( 0, 0, 7, 7 ,$i-> colorAllocate( 255, 0, 0 ));
for my $w ( 1 .. 7 ) {
my $j = GD::Image-> new( $w, $w );
$j-> copyResampled( $i, 0, 0, 0, 0, $w, $w, 8, 8 );
print "\t\t\t$w\n";
for my $y ( 0 .. $w - 1 ) {
for my $x ( 0 .. $w - 1 ) {
my ( $r ) = $j-> rgb( $j-> getPixel( $x, $y ));
printf '%x ', $r;
}
print "\n";
}
}
__END__
v5.38.0
2.78
2.3.2
1
ff
2
ff ff
ff ff
3
fe fe fe
fe fe fe
ff fe ff
4
ff ff ff ff
ff ff ff ff
ff ff ff ff
ff ff ff ff
5
fe ff ff fe ff
ff fe ff ff ff
fe fe ff ff ff
fe fe ff ff fe
ff ff ff fe ff
6
fe ff ff ff ff ff
ff ff ff ff ff fe
ff ff ff fe ff fe
ff ff ff ff ff ff
ff fe ff ff ff fe
ff fe fe ff fe ff
7
fe ff ff fe fe ff fe
ff ff ff ff ff ff fe
fe ff ff ff ff ff ff
ff ff ff ff ff ff ff
fe ff ff ff ff ff ff
ff ff ff ff ff ff ff
ff fe ff ff ff ff ff
v5.24.3
2.66
2.1.1
1
ff
2
ff ff
ff ff
3
ff ff ff
ff ff ff
ff ff ff
4
ff ff ff ff
ff ff ff ff
ff ff ff ff
ff ff ff ff
5
fe fe fe fe fe
fe fe ff fe fe
fe fe ff fe ff
ff fe fe ff fe
fe fe ff fe ff
6
ff ff ff ff ff ff
ff fe ff ff ff ff
ff ff ff ff ff ff
ff ff ff ff ff ff
ff fe ff ff ff ff
ff ff ff ff ff ff
7
fe fe ff fe ff fe fe
fe ff fe ff ff fe ff
ff fe ff ff ff fe fe
fe ff ff ff fe ff ff
ff ff ff fe fe ff fe
fe ff ff ff ff ff ff
fe ff ff ff fe ff fe
####
use strict;
use warnings;
use feature 'say';
use GD;
say $^V;
say $GD::VERSION;
say eval { GD::VERSION_STRING() } || '-';
GD::Image-> trueColor( 1 );
my $i = GD::Image-> new( 8, 8 );
$i-> filledRectangle( 0, 0, 7, 7 ,$i-> colorAllocate( 255, 0, 0 ));
for my $w ( 1 .. 7 ) {
my $j = $i-> copyScaleInterpolated( $w, $w );
print "\t\t\t$w\n";
for my $y ( 0 .. $w - 1 ) {
for my $x ( 0 .. $w - 1 ) {
my ( $r ) = $j-> rgb( $j-> getPixel( $x, $y ));
printf '%x ', $r;
}
print "\n";
}
}
__END__
v5.38.0
2.78
2.3.2
1
ff
2
ff ff
ff ff
3
ff ff ff
ff fd fd
ff fd fd
4
ff ff ff ff
ff ff ff ff
ff ff ff ff
ff ff ff ff
5
ff ff ff ff ff
ff fd fd fd fd
ff fd fd fd fd
ff fd fd fd fd
ff fd fd fd fd
6
ff ff ff ff ff ff
ff fd fd fd fd fd
ff fd fd fd fd fd
ff fd fd fd fd fd
ff fd fd fd fd fd
ff fd fd fd fd fd
7
ff ff ff ff ff ff ff
ff fd fd fd fd fd fd
ff fd fd fd fd fd fd
ff fd fd fd fd fd fd
ff fd fd fd ff fd fd
ff fd fd fd fd fd fd
ff fd fd fd fd fd fd
####
use strict;
use warnings;
use feature 'say';
use GD;
say $^V;
say $GD::VERSION;
say eval { GD::VERSION_STRING() } || '-';
GD::Image-> trueColor( 1 );
my $i = GD::Image-> new( 8, 8 );
$i-> filledRectangle( 0, 0, 7, 7 ,$i-> colorAllocate( 255, 0, 0 ));
my @ok_methods;
for my $m ( 1 .. 30 ) {
eval {
for my $w ( 1 .. 7 ) {
$i-> interpolationMethod( $m );
my $j = $i-> copyScaleInterpolated( $w, $w );
for my $y ( 0 .. $w - 1 ) {
for my $x ( 0 .. $w - 1 ) {
my ( $r ) = $j-> rgb( $j-> getPixel( $x, $y ));
die unless 255 == $r;
}
}
}
1;
} or next;
push @ok_methods, $m;
}
say 'looks like ok methods are: ', join ' ', @ok_methods;
__END__
v5.38.0
2.78
2.3.2
looks like ok methods are: 1 2 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
####
use strict;
use warnings;
use feature 'say';
use Imager;
my $i = Imager-> new( xsize => 8, ysize => 8 );
$i-> box( filled => 1, color => Imager::Color-> new( 255, 0, 0 ));
for my $w ( 1 .. 7 ) {
my $j = $i-> scale( xpixels => $w,
# qtype => 'mixing',
# qtype => 'preview',
);
print "\t\t\t$w\n";
for my $y ( 0 .. $w - 1 ) {
for my $x ( 0 .. $w - 1 ) {
my ( $r ) = $j-> getpixel( x => $x, y => $y )-> rgba;
printf '%x ', $r;
}
print "\n";
}
}
__END__
1
ff
2
ff ff
ff ff
3
ff ff ff
ff ff ff
ff ff ff
4
ff ff ff ff
ff ff ff ff
ff ff ff ff
ff ff ff ff
5
ff ff ff ff ff
ff ff ff ff ff
ff ff ff ff ff
ff ff ff ff ff
ff ff ff ff ff
6
ff ff ff ff ff ff
ff ff ff ff ff ff
ff ff ff ff ff ff
ff ff ff ff ff ff
ff ff ff ff ff ff
ff ff ff ff ff ff
7
ff ff ff ff ff ff ff
ff ff ff ff ff ff ff
ff ff ff ff ff ff ff
ff ff ff ff ff ff ff
ff ff ff ff ff ff ff
ff ff ff ff ff ff ff
ff ff ff ff ff ff ff