in reply to Corrupt JPG image in Windows

Cut & paste from perldoc -f binmode:

binmode() should be called after open() but before
any I/O is done on the filehandle.

So if you just move the binmode line to immediately after the open, you at least stand a better chance.
(No guarantee; I don't know much about windows, GD, or jpeg. But I do know perldoc :-)

The Sidhekin
print "Just another Perl ${\(trickster and hacker)},"