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 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..

In reply to Re^7: Testing image output by Anonymous Monk
in thread Testing image output by Bod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.