Ahoura Ghotbi
Ahoura Ghotbi

Reputation: 2896

perl output image from a remote source

So I am trying to use a script to simply proxy some images through it. the images are hosted on a remote server so I need to download the image and display it. This is the code I have so far:

    binmode STDOUT;
    print "Content-type: image/jpeg\n";

    #DB commands to find the image

    my $file = $image_folder."/".$file_real."0000.jpg";
    print $file;
    my $html0 = get($file);

    print $html0;

For some reason this does not work, when I change the header to html and print html0 it shows the data but when I change the header to jpeg or png it fails to compile!

Upvotes: 0

Views: 142

Answers (1)

Miller
Miller

Reputation: 35198

Need two return characters in the header:

print "Content-type: image/jpeg\n\n";

Also, should be sure that the file is loaded in binmode as well.

Upvotes: 2

Related Questions