in reply to Using a perl script as a graphic?

You have "use strict" (good job!) but you didn't predeclare $size. I don't know why your script would work from the command line; but I tried it out myself, fixed the $size problem, and it worked for me.
my $size = -s PIC;