in reply to GD segfault

print IMAGEOUT $$orientation->gif; ^^^^^^^^^^^^^
Perhaps that should be   print IMAGEOUT $img->gif;