tFPDF::_parsegif PHP Метод

_parsegif() публичный Метод

public _parsegif ( $file )
    function _parsegif($file)
    {
        // Extract info from a GIF file (via PNG conversion)
        if (!function_exists('imagepng')) {
            $this->Error('GD extension is required for GIF support');
        }
        if (!function_exists('imagecreatefromgif')) {
            $this->Error('GD has no GIF read support');
        }
        $im = imagecreatefromgif($file);
        if (!$im) {
            $this->Error('Missing or incorrect image file: ' . $file);
        }
        imageinterlace($im, 0);
        $f = @fopen('php://temp', 'rb+');
        if ($f) {
            // Perform conversion in memory
            ob_start();
            imagepng($im);
            $data = ob_get_clean();
            imagedestroy($im);
            fwrite($f, $data);
            rewind($f);
            $info = $this->_parsepngstream($f, $file);
            fclose($f);
        } else {
            // Use temporary file
            $tmp = tempnam('.', 'gif');
            if (!$tmp) {
                $this->Error('Unable to create a temporary file');
            }
            if (!imagepng($im, $tmp)) {
                $this->Error('Error while saving to temporary file');
            }
            imagedestroy($im);
            $info = $this->_parsepng($tmp);
            unlink($tmp);
        }
        return $info;
    }