|
|
Perl script that dynamically generates a 1x1 picture
So, why would you want to dynamically generate a small image that passes unnoticed on a
website?
Well, if you landed here I guess you exactly know why. Tracking purposes, forcing cookies to
be refreshed, ... you name it.
Anyway, I put together a small perl script that exactly does what I needed: Reads a file (in
this case a 1x1 BMP picture) and sends it to the browser.
This is the needed perl code:
|
#!c:/Perl/bin/Perl.exe
##
print "Content-type: image/bmp\n\n";
my $in = 'C:\Inetpub\wwwroot\1x1.bmp';
my $out = '>-';
open(IN, "< $in");
binmode(IN);
open(OUT, "$out");
binmode(OUT);
while (read(IN,$b,1)) {
$byteCount++;
print(OUT $b);
}
close(IN);
close(OUT);
|
.. and
this is a small bmp image that you can use with the perl
script above.
|
|