Category: | Web Stuff |
Author/Contact Info | dws |
Description: | A short CGI script for generating a single pixel GIF of a desired color. Useful, for example, when generating HTML that embeds color-coded, image-based bar charts. Ordinarily, using color in this way requires existing GIFs for all colors used. This script removes the need to make all of those GIFs by hand, allowing one to experiment freely. |
#!/usr/bin/perl # pixel.cgi -- Generate a single-pixel GIF of a given color. # # Usage: # <img src="pixel.cgi/CC9966.gif" width=25 height=25> # # Dave W. Smith <dws@davewsmith.com> my($rgb) = $ENV{PATH_INFO} =~ m|/([0-9A-Za-z]{6})(?:\.gif)?$|i; $rgb ||= '888888'; my $gif = pack("H*", '47494638396101000100B30000' . $rgb . 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' . 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' . 'FFFFFFFFFFFFFFFFFFFFFFFFFF2C0000' . '0000010001000004021044003B' ); binmode(STDOUT); print "Content-type: image/gif\r\n"; print "Content-length: ", length($gif), "\r\n"; print "\r\n"; print $gif; |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: On-demand single-pixel GIFs
by giulienk (Curate) on Feb 18, 2002 at 09:59 UTC | |
by true (Pilgrim) on Oct 15, 2002 at 22:49 UTC | |
by Aristotle (Chancellor) on Oct 16, 2002 at 11:52 UTC | |
Re: On-demand single-pixel GIFs
by belg4mit (Prior) on May 12, 2002 at 06:29 UTC | |
Re: On-demand single-pixel GIFs
by Anonymous Monk on Aug 20, 2014 at 23:29 UTC |
Back to
Code Catacombs