Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using image/gif 1

Status
Not open for further replies.

WintersMystic

Programmer
Aug 8, 2001
39
US
how can i use

<pre>
print &quot;Content-type: image/gif\n\n&quot;;
</pre>

in a script? i am trying to make the script to where i can call it with <img src=&quot;script.pl&quot;>. but the way i have it now is being a serious pain in the a$$ :)
 
The following code might help.

You just have to declare the header(image/gif) in the file which displays the image


===========================================
#!/usr/bin/perl

print &quot;Content-Type: image/gif\n\n&quot;;
open(IMG,&quot;../icons/apache_pb.gif&quot;) or die &quot; File open Error.&quot;;
binmode IMG;
undef $buf;
while(read IMG,$tmp,1024)
{
$buf.=$tmp;
}

print $buf;
close(IMG);

==========================================


Im not sure this is the optimised way of doing it,but this works.

HTH
C
 
Unless you have a specific image you want to display, this code will display a 1x1 pixel transparent gif, without having to open and read it from a file:
Code:
my(@bytes) = (71,73,70,56,57,97,1,0,1,0,128,0,0,255,255,255,0,0,0,33,249,4,5,20,0,0,0,44,0,0,0,0,1,0,1,0,0,2,2,68,1,0,59);
print &quot;Content-type: image/gif\n\n&quot;;
print pack('C*', @bytes);
Trust me, that string of numbers really IS a 1x1 pixel transparent gif image. I created one, opened it in a hex editor and copied the byte values. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top