download getid3.gif.php
Language: PHP
LOC: 61
Project Info
Tunez
Server: SourceForge
Type: cvs
...tunez\tunez\tunez\html\id3\
   getid3.aac.php
   getid3.ape.php
   getid3.asf.php
   getid3.au.php
   getid3.avr.php
   getid3.bmp.php
   getid3.bonk.php
   getid3.check.php
   getid3.exe.php
   getid3.flac.php
   getid3.frames.php
   getid3.functions.php
   getid3.getimagesize.php
   getid3.gif.php
   getid3.id3v1.php
   getid3.id3v2.php
   getid3.iso.php
   getid3.jpg.php
   getid3.la.php
   getid3.lookup.php
   getid3.lpac.php
   getid3.lyrics3.php
   getid3.matroska.php
   getid3.midi.php
   getid3.mod.php
   getid3.monkey.php
   getid3.mp3.php
   getid3.mpc.php
   getid3.mpeg.php
   getid3.nsv.php
   getid3.ogg.php
   getid3.ogginfo.php
   getid3.optimfrog.php
   getid3.php
   getid3.png.php
   getid3.putid3.php
   getid3.quicktime.php
   getid3.rar.php
   getid3.real.php
   getid3.rgad.php
   getid3.riff.php
   getid3.shorten.php
   getid3.swf.php
   getid3.thumbnail.php
   getid3.voc.php
   getid3.vqf.php
   getid3.write.php
   getid3.zip.php

<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org>               //
//  available at http://getid3.sourceforge.net                ///
//            or http://www.getid3.org                        ///
/////////////////////////////////////////////////////////////////
//                                                             //
// getid3.gif.php - part of getID3()                           //
// See getid3.readme.txt for more details                      //
//                                                             //
/////////////////////////////////////////////////////////////////

function getGIFHeaderFilepointer(&$fd, &$ThisFileInfo) {
	$ThisFileInfo['fileformat']                  = 'gif';
	$ThisFileInfo['video']['dataformat']         = 'gif';
	$ThisFileInfo['video']['lossless']           = true;
	$ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1;

	fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
	$GIFheader = fread($fd, 13);
	$offset = 0;

	$ThisFileInfo['gif']['header']['raw']['identifier']            =                  substr($GIFheader, $offset, 3);
	$offset += 3;

	if ($ThisFileInfo['gif']['header']['raw']['identifier'] != 'GIF') {
		$ThisFileInfo['error'] .= "\n".'Expecting "GIF" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$ThisFileInfo['gif']['header']['raw']['identifier'].'"';
		unset($ThisFileInfo['fileformat']);
		unset($ThisFileInfo['gif']);
		return false;
	}

	$ThisFileInfo['gif']['header']['raw']['version']               =                  substr($GIFheader, $offset, 3);
	$offset += 3;
	$ThisFileInfo['gif']['header']['raw']['width']                 = LittleEndian2Int(substr($GIFheader, $offset, 2));
	$offset += 2;
	$ThisFileInfo['gif']['header']['raw']['height']                = LittleEndian2Int(substr($GIFheader, $offset, 2));
	$offset += 2;
	$ThisFileInfo['gif']['header']['raw']['flags']                 = LittleEndian2Int(substr($GIFheader, $offset, 1));
	$offset += 1;
	$ThisFileInfo['gif']['header']['raw']['bg_color_index']        = LittleEndian2Int(substr($GIFheader, $offset, 1));
	$offset += 1;
	$ThisFileInfo['gif']['header']['raw']['aspect_ratio']          = LittleEndian2Int(substr($GIFheader, $offset, 1));
	$offset += 1;

	$ThisFileInfo['video']['resolution_x']                         = $ThisFileInfo['gif']['header']['raw']['width'];
	$ThisFileInfo['video']['resolution_y']                         = $ThisFileInfo['gif']['header']['raw']['height'];
	$ThisFileInfo['gif']['version']                                = $ThisFileInfo['gif']['header']['raw']['version'];
	$ThisFileInfo['gif']['header']['flags']['global_color_table']  = (bool) ($ThisFileInfo['gif']['header']['raw']['flags'] & 0x80);
	if ($ThisFileInfo['gif']['header']['raw']['flags'] & 0x80) {
		// Number of bits per primary color available to the original image, minus 1
		$ThisFileInfo['gif']['header']['bits_per_pixel']  = 3 * ((($ThisFileInfo['gif']['header']['raw']['flags'] & 0x70) >> 4) + 1);
	} else {
		$ThisFileInfo['gif']['header']['bits_per_pixel']  = 0;
	}
	$ThisFileInfo['gif']['header']['flags']['global_color_sorted'] = (bool) ($ThisFileInfo['gif']['header']['raw']['flags'] & 0x40);
	if ($ThisFileInfo['gif']['header']['flags']['global_color_table']) {
		// the number of bytes contained in the Global Color Table. To determine that
		// actual size of the color table, raise 2 to [the value of the field + 1]
		$ThisFileInfo['gif']['header']['global_color_size'] = pow(2, ($ThisFileInfo['gif']['header']['raw']['flags'] & 0x07) + 1);
		$ThisFileInfo['video']['bits_per_sample']           = ($ThisFileInfo['gif']['header']['raw']['flags'] & 0x07) + 1;
	} else {
		$ThisFileInfo['gif']['header']['global_color_size'] = 0;
	}
	if ($ThisFileInfo['gif']['header']['raw']['aspect_ratio'] != 0) {
		// Aspect Ratio = (Pixel Aspect Ratio + 15) / 64
		$ThisFileInfo['gif']['header']['aspect_ratio']             = ($ThisFileInfo['gif']['header']['raw']['aspect_ratio'] + 15) / 64;
	}

	if ($ThisFileInfo['gif']['header']['flags']['global_color_table']) {
		$GIFcolorTable = fread($fd, 3 * $ThisFileInfo['gif']['header']['global_color_size']);
		$offset = 0;
		for ($i = 0; $i < $ThisFileInfo['gif']['header']['global_color_size']; $i++) {
			//$ThisFileInfo['gif']['global_color_table']['red'][$i]   = LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
			//$ThisFileInfo['gif']['global_color_table']['green'][$i] = LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
			//$ThisFileInfo['gif']['global_color_table']['blue'][$i]  = LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
			$red   = LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
			$green = LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
			$blue  = LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
			$ThisFileInfo['gif']['global_color_table'][$i] = (($red << 16) | ($green << 8) | ($blue));
		}
	}

	return true;
}

?>

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us