[rt-devel] Statistics3 package - corrupted PNG images

Alex Rebrik arebrik at zappos.com
Fri Jan 30 17:18:48 EST 2004


Hi everyone,

I've noticed quite a few messages on the lists regarding corrupted 
graphs' images genereated by Haralad Wagener's Statistics3 package. I 
too was faced with the same problem, particularly new-line being added 
in the begining of image output resulting in broken PNG image header. 
While I didn't find any practicle resolution to this issue in the list 
archive I was nevertheless able to solve the problem a few ways. Here is 
what I did:

1. I figured out that when printing to a file images are generated 
properly. So explicitly specified the STDOUT descriptor in print 
statement and that resulted in proper image being generated. So for 
example in "Statistics/Resolution/Elements/Chart" print satement looks like:

<%perl>
print STDOUT $graph->plot(\@data)->$format();
---SNIP---

2. Reading up on HTML::Mason I found out that Mason buffers all its 
output but gives you a way to clear the buffer. Next thing I tried is to 
revert to original print statement without explicitly naming STDOUT 
descriptor but clearing the output buffer beforehand. This also has 
worked and generated proper images not prepended by a newline.

<%perl>
$m->clear_buffer();
print $graph->plot(\@data)->$format();
---SNIP---

3. HTML::Mason has a preferred output method $m->out(), replacing print 
statement with $m->out has also worked, but $m->clear_buffer() was still 
necessary to avoid newline injection.

<%perl>
$m->clear_buffer();
$m->out($graph->plot(\@data)->$format());
---SNIP---

Hope this is helpful to some of you having similar issues.

--Alex




More information about the Rt-devel mailing list