> Ok, here is the od output:
>
> X:\avs_templates>od out\1\images\gd.png
> 0000000 005015 050211 043516 006415 015012 005015 000000 006400
> 0000020 044111 051104 000000 144000 000000 062000 001401 000000
> 0000040 174400 166510 000110 000000 050006 052114 000105 000000
> 0000060 000377 015400 106777 000042 000000 044610 040504 074124
> 0000100 166634 130720 005015 030402 143014 100361 012035 176644
> 0000120 161342 043630 152761 170076 056020 156274 161746 102132
> 0000140 161403 046721 171234 031037 043764 124511 173110 170353
> 0000160 023236 005702 066245 012005 161766 070215 005425 147322
> 0000200 013165 112714 060645 005015 163602 015002 013026 112170
> 0000220 025635 101170 134567 036707 053507 055243 135427 100505
> 0000240 104127 176402 020716 175212 001036 027327 174230 173041
> 0000260 153360 133726 137535 100677 064062 066454 054404 062626
> 0000300 113131 137775 027427 015313 013305 123006 000375 000000
> 0000320 044400 047105 127104 060102 000202
> 0000331
Ok, after converting this to hex, switching the endianess (I'm on
a sparc/solaris box currently) you can see the files are:
farside 1% od -c bad.png
0000000 \r \n 211 P N G \r \r \n 032 \r \n \0 \0 \0 \r
0000020 I H D R \0 \0 \0 310 \0 \0 \0 d 001 003 \0 \0
[snip]
farside 2% od -c good.png
0000000 211 P N G \r \n 032 \n \0 \0 \0 \r I H D R
0000020 \0 \0 \0 310 \0 \0 \0 d 001 003 \0 \0 \0 371 H 355
[snip]
There are two problems:
- the bad file has a initial newline (\n or 0xa)
- every newline in the bad file has an extra return (\r or 0xd).
The initial newline is most likely some extraneous whitespace introduced
somewhere in your template. Since it only happens with ttree you should
look at the wrapper. Remove the GD althogether (or replace it with a
single string, say "XXX") and make sure you get no output (or just "XXX").
The replacement of \n with \r\n is a windoze text versus binary mode
issue. You need to change the output to binary mode on windoze. Try
using stdout(binmode) or redirect(file, binmode).
Craig