Thanks for your help,
I have commented out any reference to print "Content-type: text/html\n\n";
replacing the initial print header with print "Content-type: image/jpeg\n\n";
using the line print $newimage->jpeg;
Now I get an empty image with the "X"