in reply to Problem reading image from perl cgi script

Try replacing "BINMODE" with "binmode", and do it after you've opened the file.

Also, for what you're doing, CGI.pm is overkill.   print "Content-type: image/jpeg\n\n", $data1; is sufficient.

Also, unless you have access to server error logs, you might consider a fallback strategy for error handling. Instead of die(), why not emit a blank (or black, or red, or orange) image? You can borrow code from On-demand single-pixel GIFs to make that work.