in reply to PDF::API2 and Imager

Please run perl -d on your script and see if you can get a stack back trace from the debugger as this will help localize the problem. Are you sure that $img and $result are defined?