Zend - The PHP Company




Graphics

Add Code


phpixel  

Type: code fragment
Added by: tulipan
Entered: 04/07/2000
Last modified: 08/12/1999
Rating: ***** (24 votes)
Views: 11005
used to generate a transparent or colored pixel.
syntax:
<img src="phpixel.php3"> for a transparent pixel
<img src="phpixel.php3?c=ff0000"> for a red pixel
no gd library needed... only pure php


<?php 

// output of 1 pixel transparent gif 
// for counters etc. 
// Ulrich Babiak, Koeln 1999/11/30 

// syntax: <img src="phpixel.php3"> for a transparent pixel
//     or: <img src="phpixel.php3?c=FFFF00"> for a yellow pixel
// (color added by Thomas Sch��ler, Bonn 2000/7/2)

// some Headers to prevent caching 

Header"Content-type:  image/gif"); 
Header"Expires: Wed, 11 Nov 1998 11:11:11 GMT"); 
Header"Cache-Control: no-cache"); 
Header"Cache-Control: must-revalidate"); 

// if # is in front of the hex-string
$rgb str_replace("#"""$c); 

$r hexdec(substr ($rgb0,2));
$g hexdec(substr ($rgb2,2));
$b hexdec(substr ($rgb4,2));

if(
$c){
printf ("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",
71,73,70,56,57,97,1,0,1,0,128,0,0,$r,$g,$b,0,0,0,44,0,0,0,0,1,0,1,0,0,2,2,68,1,0,59); 
}
else{
printf ("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%",
71,73,70,56,57,97,1,0,1,0,128,255,0,192,192,192,0,0,0,33,249,4,1,0,0,0,0,44,0,0,0,0,1,0,1,0,0,2,2,68,1,0,59); 
}

?>


Usage Example




Rate This Script





Search



This Category All Categories