Skip to content

Commit

Permalink
bugfix #183 Reduce information for GIF files
Browse files Browse the repository at this point in the history
#183
If getid3->option_extra_info == false, do not parse or return
global_color_table, do not return extension_blocks
  • Loading branch information
JamesHeinrich committed May 11, 2019
1 parent 101a56c commit fe4e0a5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion getid3/getid3.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class getID3
*/
protected $startup_warning = '';

const VERSION = '1.9.17-201904221453';
const VERSION = '1.9.17-201905102117';
const FREAD_BUFFER_SIZE = 32768;

const ATTACHMENTS_NONE = false;
Expand Down
23 changes: 16 additions & 7 deletions getid3/module.graphic.gif.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public function Analyze() {
return false;
}

//if (!$this->getid3->option_extra_info) {
// $this->warning('GIF Extensions and Global Color Table not returned due to !getid3->option_extra_info');
//}

$info['gif']['header']['raw']['version'] = substr($GIFheader, $offset, 3);
$offset += 3;
$info['gif']['header']['raw']['width'] = getid3_lib::LittleEndian2Int(substr($GIFheader, $offset, 2));
Expand Down Expand Up @@ -85,12 +89,15 @@ public function Analyze() {

if ($info['gif']['header']['flags']['global_color_table']) {
$GIFcolorTable = $this->fread(3 * $info['gif']['header']['global_color_size']);
$offset = 0;
for ($i = 0; $i < $info['gif']['header']['global_color_size']; $i++) {
$red = getid3_lib::LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
$green = getid3_lib::LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
$blue = getid3_lib::LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
$info['gif']['global_color_table'][$i] = (($red << 16) | ($green << 8) | ($blue));
if ($this->getid3->option_extra_info) {
$offset = 0;
for ($i = 0; $i < $info['gif']['header']['global_color_size']; $i++) {
$red = getid3_lib::LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
$green = getid3_lib::LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
$blue = getid3_lib::LittleEndian2Int(substr($GIFcolorTable, $offset++, 1));
$info['gif']['global_color_table'][$i] = (($red << 16) | ($green << 8) | ($blue));
$info['gif']['global_color_table_rgb'][$i] = sprintf('%02X%02X%02X', $red, $green, $blue);
}
}
}

Expand Down Expand Up @@ -166,7 +173,9 @@ public function Analyze() {
}
}

$info['gif']['extension_blocks'][] = $ExtensionBlock;
if ($this->getid3->option_extra_info) {
$info['gif']['extension_blocks'][] = $ExtensionBlock;
}
break;

case ';':
Expand Down

0 comments on commit fe4e0a5

Please sign in to comment.