#native_company# #native_desc#
#native_cta#

GifPix – create gif on the fly without GD

By Bernd Schnitzer
on October 9, 2001

Version: 1.2

Type: Class

Category: Graphics

License: GNU General Public License

Description: Create a 1×1 gif file without GD; just say the color. You can create a incolor image too. Make to use with stats bars.

<?php
class gifpix {
// by Bernd Schnitzer <[email protected]>

	var $start = '47494638396101000100800000';
	var $color = 'ffffff';
	var $black = '000000';
	var $marker = '21f904';
	var $transparent = '01';
	var $end = '000000002c00000000010001000002024401003b';
	
	function hex2bin($s) {
		for ($i = 0; $i < strlen($s); $i += 2) { 
			$bin .= chr(hexdec(substr($s,$i,2))); 
		} 
		return $bin; 
	}

	function create($color = -1) {
		if (($color!= -1) && (strlen($color)==6)) {
			$this->transparent = '00';
			if ($color == '000000')
				$this->black = 'ffffff';
			$this->color = $color;
		}
		$hex = $this->start.$this->color.$this->black.$this->marker.$this->transparent.$this->end;
		return $this->hex2bin($hex);
	}
}


header("Content-Type: image/gif");
$gifpix = new gifpix();

// color:
print $gifpix->create('0000ff');


// transparent:
//print $gifpix->create();

?>