Exemplo n.º 1
0
 function _parsegif($file, $mem = false)
 {
     require_once 'gif.php';
     $h = 0;
     $w = 0;
     $gif = new CGIF();
     if ($mem) {
         $ret = $gif->loadFile_mem($file, 0);
     } else {
         $ret = $gif->loadFile($file, 0);
     }
     if (!$ret) {
         return null;
     }
     if (empty($gif->m_img->m_data)) {
         return null;
     }
     if ($gif->m_img->m_gih->m_bLocalClr) {
         $nColors = $gif->m_img->m_gih->m_nTableSize;
         $pal = $gif->m_img->m_gih->m_colorTable->toString();
         $colspace = 'Indexed';
     } elseif ($gif->m_gfh->m_bGlobalClr) {
         $nColors = $gif->m_gfh->m_nTableSize;
         $pal = $gif->m_gfh->m_colorTable->toString();
         $colspace = 'Indexed';
     } else {
         $nColors = 0;
         $colspace = 'DeviceGray';
         $pal = '';
     }
     $trns = '';
     if ($gif->m_img->m_bTrans && $nColors > 0) {
         $trns = array($gif->m_img->m_nTrans);
     }
     $data = $gif->m_img->m_data;
     $w = $gif->m_gfh->m_nWidth;
     $h = $gif->m_gfh->m_nHeight;
     if ($colspace == 'Indexed' and empty($pal)) {
         return false;
     }
     if ($this->compress) {
         $data = gzcompress($data);
         return array('w' => $w, 'h' => $h, 'cs' => $colspace, 'bpc' => 8, 'f' => 'FlateDecode', 'pal' => $pal, 'trns' => $trns, 'data' => $data);
     } else {
         return array('w' => $w, 'h' => $h, 'cs' => $colspace, 'bpc' => 8, 'pal' => $pal, 'trns' => $trns, 'data' => $data);
     }
 }