Mega Code Archive

 
Categories / Php / Graphics
 

GifPix - create gif on the fly without GD

<?php class gifpix { 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(); ?>