in reply to Re^6: Testing image output
in thread Testing image output

Not doubt from copyResampled.

No. It's from you :-) -- not providing a line of code for stroke not being drawn. The copyResampled deficiencies discussed previously are not applicable if there's no scaling. It works as simple copy then, all tests are passed.

I think the intention to test for correct image content was commendable, it's sad if you give up, though it's your module of course. With no scaling, tests must pass, if just one fails then GD is paperweight, sorry.

Somewhat tangential, in code above you overshoot by 1 px i.e. address coordinate outside canvas, drawing rectangle for e.g. $center. Similarly, for $horizontal, rectangle clearly intended to be centered being NOT centered hurts my eyes badly :-). "5" in png(5) is a bit sore in the eye also

Further off topic and pure speculation: I doubt that vague description of copyResampled is there to perpetually tweak/improve. It simply stems from long time ago when no solid and well understood (and correct) interpolation methods were implemented in GD. Anything better that nearest neighbour to avoid jagged lines was welcome. Then something close to bilinear scaling was quickly added. Though even then this method was not state-of-the-art, implemented elsewhere, described in papers, etc.

Now completely off topic: checking your test failures, I was unfortunate to investigate how rectangle is stroked in GD. Looks like for lines thicker than 1 px, vertical fragments are drawn 1 px wider than horizontal fragments. It doesn't happen for stand-alone lines (left side in picture below), only for rectangles. Am I missing something? Or is it a bug? All the time being present there, for 30 or so years, then? Thing as simple as stroked frame... So much about

expecting that libgd and/or the GD::Image wrapper around that library together have sufficient tests ... to ensure that it works in any situation they claim it will work
use strict; use warnings; use GD; sub dump_red { my $gd = shift; my ( $w, $h ) = $gd-> getBounds; for my $y ( 0 .. $h - 1 ) { for my $x ( 0 .. $w - 1 ) { my ( $r ) = $gd-> rgb( $gd-> getPixel( $x, $y )); printf $r ? ( '%02x ', $r ) : '.. '; } print "\n"; } } my $i = GD::Image-> new( 23, 15, 1 ); my $r = $i-> colorAllocate( 255, 0, 0 ); $i-> line( 1, 2, 5, 2, $r ); $i-> line( 1, 9, 1, 13, $r ); $i-> rectangle( 7, 2, 10, 11, $r ); $i-> setThickness( 3 ); $i-> line( 1, 5, 5, 5, $r ); $i-> line( 4, 9, 4, 13, $r ); $i-> rectangle( 13, 2, 20, 11, $r ); dump_red( $i ); __END__ .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 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 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 .. 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 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 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..