I worked it out in the end. Its head slappingly simple Thanks everyone Heres the finished script:-
#!/usr/bin/perl -w =comment This is for customer proofs NOT cam/management proofs Responds to a request for a customer proof image from the internet +. Reads the requested image from disk and serves it back to the brow +ser. Used to serve private images that are not on the apache tree in re +sponse to a browser request to fill an image tag eg <img src=\"http://www.caralan.com/cgi-bin/customer_image_server.cg +i?load_image=cust__stevecaralancom1129266425_00.gif\" border=\"0\" a +lt=\"\"> =cut use strict; use CGI; #use File::Copy; #use Tie::File; #use Fcntl qw( :DEFAULT :flock ); use steves_general_functions; my $mycgi = new CGI; my $imagedata = ""; my $load_image = $mycgi->param( "load_image" ); $load_image = &gen_wash_input($load_image, "filename"); my $proof_folder = "/caralan_com/system/proofing/customer_proofs/proof +s_out/"; my $imagefile = $proof_folder . $load_image; #Set mime type for returned binary dump if( lc(&gen_get_extension_from_path($imagefile)) eq ".gif"){ print "Content-type: image/gif\n\n"; } if( lc(&gen_get_extension_from_path($imagefile)) eq ".jpg"){ print "Content-type: image/jpeg\n\n"; } if( lc(&gen_get_extension_from_path($imagefile)) eq ".tif"){ print "Content-type: image/tif\n\n"; } #Slurp binary image data from diskfile { local( $/, *IMAGEFILE ) ; open( IMAGEFILE, $imagefile ); $imagedata = <IMAGEFILE>; close IMAGEFILE; } #Send binary dump to browser print $imagedata;

In reply to Re^3: Serving images with perl by fluffyvoidwarrior
in thread Serving images with perl by fluffyvoidwarrior

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.