in reply to CGI script bringing its own data

the Official GD documentation gives one example that should do what you want.
open (PNG,"barnswallow.png") || die; $myImage = newFromPng GD::Image(\*PNG) || die; close PNG;