You set binmode STDOUT; when I think you meant to set binmode FILE;.
In reply to Re: Add text to image by gmargo in thread Add text to image by xachen