add piwik installation
This commit is contained in:
parent
90aa4ef157
commit
8c5d4f0c31
3197 changed files with 563902 additions and 0 deletions
BIN
www/analytics/libs/tcpdf/include/sRGB.icc
Normal file
BIN
www/analytics/libs/tcpdf/include/sRGB.icc
Normal file
Binary file not shown.
462
www/analytics/libs/tcpdf/include/tcpdf_colors.php
Normal file
462
www/analytics/libs/tcpdf/include/tcpdf_colors.php
Normal file
|
|
@ -0,0 +1,462 @@
|
|||
<?php
|
||||
//============================================================+
|
||||
// File name : tcpdf_colors.php
|
||||
// Version : 1.0.003
|
||||
// Begin : 2002-04-09
|
||||
// Last Update : 2013-10-25
|
||||
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
|
||||
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
|
||||
// -------------------------------------------------------------------
|
||||
// Copyright (C) 2002-2013 Nicola Asuni - Tecnick.com LTD
|
||||
//
|
||||
// This file is part of TCPDF software library.
|
||||
//
|
||||
// TCPDF is free software: you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// TCPDF is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with TCPDF. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// See LICENSE.TXT file for more information.
|
||||
// -------------------------------------------------------------------
|
||||
//
|
||||
// Description : Array of WEB safe colors
|
||||
//
|
||||
//============================================================+
|
||||
|
||||
/**
|
||||
* @file
|
||||
* PHP color class for TCPDF
|
||||
* @author Nicola Asuni
|
||||
* @package com.tecnick.tcpdf
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TCPDF_COLORS
|
||||
* PHP color class for TCPDF
|
||||
* @package com.tecnick.tcpdf
|
||||
* @version 1.0.003
|
||||
* @author Nicola Asuni - info@tecnick.com
|
||||
*/
|
||||
class TCPDF_COLORS {
|
||||
|
||||
/**
|
||||
* Array of WEB safe colors
|
||||
* @public static
|
||||
*/
|
||||
public static $webcolor = array (
|
||||
'aliceblue' => 'f0f8ff',
|
||||
'antiquewhite' => 'faebd7',
|
||||
'aqua' => '00ffff',
|
||||
'aquamarine' => '7fffd4',
|
||||
'azure' => 'f0ffff',
|
||||
'beige' => 'f5f5dc',
|
||||
'bisque' => 'ffe4c4',
|
||||
'black' => '000000',
|
||||
'blanchedalmond' => 'ffebcd',
|
||||
'blue' => '0000ff',
|
||||
'blueviolet' => '8a2be2',
|
||||
'brown' => 'a52a2a',
|
||||
'burlywood' => 'deb887',
|
||||
'cadetblue' => '5f9ea0',
|
||||
'chartreuse' => '7fff00',
|
||||
'chocolate' => 'd2691e',
|
||||
'coral' => 'ff7f50',
|
||||
'cornflowerblue' => '6495ed',
|
||||
'cornsilk' => 'fff8dc',
|
||||
'crimson' => 'dc143c',
|
||||
'cyan' => '00ffff',
|
||||
'darkblue' => '00008b',
|
||||
'darkcyan' => '008b8b',
|
||||
'darkgoldenrod' => 'b8860b',
|
||||
'dkgray' => 'a9a9a9',
|
||||
'darkgray' => 'a9a9a9',
|
||||
'darkgrey' => 'a9a9a9',
|
||||
'darkgreen' => '006400',
|
||||
'darkkhaki' => 'bdb76b',
|
||||
'darkmagenta' => '8b008b',
|
||||
'darkolivegreen' => '556b2f',
|
||||
'darkorange' => 'ff8c00',
|
||||
'darkorchid' => '9932cc',
|
||||
'darkred' => '8b0000',
|
||||
'darksalmon' => 'e9967a',
|
||||
'darkseagreen' => '8fbc8f',
|
||||
'darkslateblue' => '483d8b',
|
||||
'darkslategray' => '2f4f4f',
|
||||
'darkslategrey' => '2f4f4f',
|
||||
'darkturquoise' => '00ced1',
|
||||
'darkviolet' => '9400d3',
|
||||
'deeppink' => 'ff1493',
|
||||
'deepskyblue' => '00bfff',
|
||||
'dimgray' => '696969',
|
||||
'dimgrey' => '696969',
|
||||
'dodgerblue' => '1e90ff',
|
||||
'firebrick' => 'b22222',
|
||||
'floralwhite' => 'fffaf0',
|
||||
'forestgreen' => '228b22',
|
||||
'fuchsia' => 'ff00ff',
|
||||
'gainsboro' => 'dcdcdc',
|
||||
'ghostwhite' => 'f8f8ff',
|
||||
'gold' => 'ffd700',
|
||||
'goldenrod' => 'daa520',
|
||||
'gray' => '808080',
|
||||
'grey' => '808080',
|
||||
'green' => '008000',
|
||||
'greenyellow' => 'adff2f',
|
||||
'honeydew' => 'f0fff0',
|
||||
'hotpink' => 'ff69b4',
|
||||
'indianred' => 'cd5c5c',
|
||||
'indigo' => '4b0082',
|
||||
'ivory' => 'fffff0',
|
||||
'khaki' => 'f0e68c',
|
||||
'lavender' => 'e6e6fa',
|
||||
'lavenderblush' => 'fff0f5',
|
||||
'lawngreen' => '7cfc00',
|
||||
'lemonchiffon' => 'fffacd',
|
||||
'lightblue' => 'add8e6',
|
||||
'lightcoral' => 'f08080',
|
||||
'lightcyan' => 'e0ffff',
|
||||
'lightgoldenrodyellow' => 'fafad2',
|
||||
'ltgray' => 'd3d3d3',
|
||||
'lightgray' => 'd3d3d3',
|
||||
'lightgrey' => 'd3d3d3',
|
||||
'lightgreen' => '90ee90',
|
||||
'lightpink' => 'ffb6c1',
|
||||
'lightsalmon' => 'ffa07a',
|
||||
'lightseagreen' => '20b2aa',
|
||||
'lightskyblue' => '87cefa',
|
||||
'lightslategray' => '778899',
|
||||
'lightslategrey' => '778899',
|
||||
'lightsteelblue' => 'b0c4de',
|
||||
'lightyellow' => 'ffffe0',
|
||||
'lime' => '00ff00',
|
||||
'limegreen' => '32cd32',
|
||||
'linen' => 'faf0e6',
|
||||
'magenta' => 'ff00ff',
|
||||
'maroon' => '800000',
|
||||
'mediumaquamarine' => '66cdaa',
|
||||
'mediumblue' => '0000cd',
|
||||
'mediumorchid' => 'ba55d3',
|
||||
'mediumpurple' => '9370d8',
|
||||
'mediumseagreen' => '3cb371',
|
||||
'mediumslateblue' => '7b68ee',
|
||||
'mediumspringgreen' => '00fa9a',
|
||||
'mediumturquoise' => '48d1cc',
|
||||
'mediumvioletred' => 'c71585',
|
||||
'midnightblue' => '191970',
|
||||
'mintcream' => 'f5fffa',
|
||||
'mistyrose' => 'ffe4e1',
|
||||
'moccasin' => 'ffe4b5',
|
||||
'navajowhite' => 'ffdead',
|
||||
'navy' => '000080',
|
||||
'oldlace' => 'fdf5e6',
|
||||
'olive' => '808000',
|
||||
'olivedrab' => '6b8e23',
|
||||
'orange' => 'ffa500',
|
||||
'orangered' => 'ff4500',
|
||||
'orchid' => 'da70d6',
|
||||
'palegoldenrod' => 'eee8aa',
|
||||
'palegreen' => '98fb98',
|
||||
'paleturquoise' => 'afeeee',
|
||||
'palevioletred' => 'd87093',
|
||||
'papayawhip' => 'ffefd5',
|
||||
'peachpuff' => 'ffdab9',
|
||||
'peru' => 'cd853f',
|
||||
'pink' => 'ffc0cb',
|
||||
'plum' => 'dda0dd',
|
||||
'powderblue' => 'b0e0e6',
|
||||
'purple' => '800080',
|
||||
'red' => 'ff0000',
|
||||
'rosybrown' => 'bc8f8f',
|
||||
'royalblue' => '4169e1',
|
||||
'saddlebrown' => '8b4513',
|
||||
'salmon' => 'fa8072',
|
||||
'sandybrown' => 'f4a460',
|
||||
'seagreen' => '2e8b57',
|
||||
'seashell' => 'fff5ee',
|
||||
'sienna' => 'a0522d',
|
||||
'silver' => 'c0c0c0',
|
||||
'skyblue' => '87ceeb',
|
||||
'slateblue' => '6a5acd',
|
||||
'slategray' => '708090',
|
||||
'slategrey' => '708090',
|
||||
'snow' => 'fffafa',
|
||||
'springgreen' => '00ff7f',
|
||||
'steelblue' => '4682b4',
|
||||
'tan' => 'd2b48c',
|
||||
'teal' => '008080',
|
||||
'thistle' => 'd8bfd8',
|
||||
'tomato' => 'ff6347',
|
||||
'turquoise' => '40e0d0',
|
||||
'violet' => 'ee82ee',
|
||||
'wheat' => 'f5deb3',
|
||||
'white' => 'ffffff',
|
||||
'whitesmoke' => 'f5f5f5',
|
||||
'yellow' => 'ffff00',
|
||||
'yellowgreen' => '9acd32'
|
||||
); // end of web colors
|
||||
|
||||
/**
|
||||
* Array of valid JavaScript color names
|
||||
* @public static
|
||||
*/
|
||||
public static $jscolor = array ('transparent', 'black', 'white', 'red', 'green', 'blue', 'cyan', 'magenta', 'yellow', 'dkGray', 'gray', 'ltGray');
|
||||
|
||||
/**
|
||||
* Array of Spot colors (C,M,Y,K,name)
|
||||
* Color keys must be in lowercase and without spaces.
|
||||
* As long as no open standard for spot colours exists, you have to buy a colour book by one of the colour manufacturers and insert the values and names of spot colours directly.
|
||||
* Common industry standard spot colors are: ANPA-COLOR, DIC, FOCOLTONE, GCMI, HKS, PANTONE, TOYO, TRUMATCH.
|
||||
* @public static
|
||||
*/
|
||||
public static $spotcolor = array (
|
||||
// special registration colors
|
||||
'none' => array( 0, 0, 0, 0, 'None'),
|
||||
'all' => array(100, 100, 100, 100, 'All'),
|
||||
// standard CMYK colors
|
||||
'cyan' => array(100, 0, 0, 0, 'Cyan'),
|
||||
'magenta' => array( 0, 100, 0, 0, 'Magenta'),
|
||||
'yellow' => array( 0, 0, 100, 0, 'Yellow'),
|
||||
'key' => array( 0, 0, 0, 100, 'Key'),
|
||||
// alias
|
||||
'white' => array( 0, 0, 0, 0, 'White'),
|
||||
'black' => array( 0, 0, 0, 100, 'Black'),
|
||||
// standard RGB colors
|
||||
'red' => array( 0, 100, 100, 0, 'Red'),
|
||||
'green' => array(100, 0, 100, 0, 'Green'),
|
||||
'blue' => array(100, 100, 0, 0, 'Blue'),
|
||||
// Add here standard spot colors or dynamically define them with AddSpotColor()
|
||||
// ...
|
||||
); // end of spot colors
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
/**
|
||||
* Return the Spot color array.
|
||||
* @param $name (string) Name of the spot color.
|
||||
* @param $spotc (array) Reference to an array of spot colors.
|
||||
* @return (array) Spot color array or false if not defined.
|
||||
* @since 5.9.125 (2011-10-03)
|
||||
* @public static
|
||||
*/
|
||||
public static function getSpotColor($name, &$spotc) {
|
||||
if (isset($spotc[$name])) {
|
||||
return $spotc[$name];
|
||||
}
|
||||
$color = preg_replace('/[\s]*/', '', $name); // remove extra spaces
|
||||
$color = strtolower($color);
|
||||
if (isset(self::$spotcolor[$color])) {
|
||||
if (!isset($spotc[$name])) {
|
||||
$i = (1 + count($spotc));
|
||||
$spotc[$name] = array('C' => self::$spotcolor[$color][0], 'M' => self::$spotcolor[$color][1], 'Y' => self::$spotcolor[$color][2], 'K' => self::$spotcolor[$color][3], 'name' => self::$spotcolor[$color][4], 'i' => $i);
|
||||
}
|
||||
return $spotc[self::$spotcolor[$color][4]];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array (RGB or CMYK) from an html color name, or a six-digit (i.e. #3FE5AA), or three-digit (i.e. #7FF) hexadecimal color, or a javascript color array, or javascript color name.
|
||||
* @param $hcolor (string) HTML color.
|
||||
* @param $spotc (array) Reference to an array of spot colors.
|
||||
* @param $defcol (array) Color to return in case of error.
|
||||
* @return array RGB or CMYK color, or false in case of error.
|
||||
* @public static
|
||||
*/
|
||||
public static function convertHTMLColorToDec($hcolor, &$spotc, $defcol=array('R'=>128,'G'=>128,'B'=>128)) {
|
||||
$color = preg_replace('/[\s]*/', '', $hcolor); // remove extra spaces
|
||||
$color = strtolower($color);
|
||||
// check for javascript color array syntax
|
||||
if (strpos($color, '[') !== false) {
|
||||
if (preg_match('/[\[][\"\'](t|g|rgb|cmyk)[\"\'][\,]?([0-9\.]*)[\,]?([0-9\.]*)[\,]?([0-9\.]*)[\,]?([0-9\.]*)[\]]/', $color, $m) > 0) {
|
||||
$returncolor = array();
|
||||
switch ($m[1]) {
|
||||
case 'cmyk': {
|
||||
// RGB
|
||||
$returncolor['C'] = max(0, min(100, (floatval($m[2]) * 100)));
|
||||
$returncolor['M'] = max(0, min(100, (floatval($m[3]) * 100)));
|
||||
$returncolor['Y'] = max(0, min(100, (floatval($m[4]) * 100)));
|
||||
$returncolor['K'] = max(0, min(100, (floatval($m[5]) * 100)));
|
||||
break;
|
||||
}
|
||||
case 'rgb': {
|
||||
// RGB
|
||||
$returncolor['R'] = max(0, min(255, (floatval($m[2]) * 255)));
|
||||
$returncolor['G'] = max(0, min(255, (floatval($m[3]) * 255)));
|
||||
$returncolor['B'] = max(0, min(255, (floatval($m[4]) * 255)));
|
||||
break;
|
||||
}
|
||||
case 'g': {
|
||||
// grayscale
|
||||
$returncolor['G'] = max(0, min(255, (floatval($m[2]) * 255)));
|
||||
break;
|
||||
}
|
||||
case 't':
|
||||
default: {
|
||||
// transparent (empty array)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $returncolor;
|
||||
}
|
||||
} elseif ((substr($color, 0, 4) != 'cmyk') AND ($dotpos = strpos($color, '.')) !== false) {
|
||||
// remove class parent (i.e.: color.red)
|
||||
$color = substr($color, ($dotpos + 1));
|
||||
if ($color == 'transparent') {
|
||||
// transparent (empty array)
|
||||
return array();
|
||||
}
|
||||
}
|
||||
if (strlen($color) == 0) {
|
||||
return $defcol;
|
||||
}
|
||||
// RGB ARRAY
|
||||
if (substr($color, 0, 3) == 'rgb') {
|
||||
$codes = substr($color, 4);
|
||||
$codes = str_replace(')', '', $codes);
|
||||
$returncolor = explode(',', $codes);
|
||||
foreach ($returncolor as $key => $val) {
|
||||
if (strpos($val, '%') > 0) {
|
||||
// percentage
|
||||
$returncolor[$key] = (255 * intval($val) / 100);
|
||||
} else {
|
||||
$returncolor[$key] = intval($val);
|
||||
}
|
||||
// normalize value
|
||||
$returncolor[$key] = max(0, min(255, $returncolor[$key]));
|
||||
}
|
||||
return $returncolor;
|
||||
}
|
||||
// CMYK ARRAY
|
||||
if (substr($color, 0, 4) == 'cmyk') {
|
||||
$codes = substr($color, 5);
|
||||
$codes = str_replace(')', '', $codes);
|
||||
$returncolor = explode(',', $codes);
|
||||
foreach ($returncolor as $key => $val) {
|
||||
if (strpos($val, '%') !== false) {
|
||||
// percentage
|
||||
$returncolor[$key] = (100 * intval($val) / 100);
|
||||
} else {
|
||||
$returncolor[$key] = intval($val);
|
||||
}
|
||||
// normalize value
|
||||
$returncolor[$key] = max(0, min(100, $returncolor[$key]));
|
||||
}
|
||||
return $returncolor;
|
||||
}
|
||||
if ($color{0} != '#') {
|
||||
// COLOR NAME
|
||||
if (isset(self::$webcolor[$color])) {
|
||||
// web color
|
||||
$color_code = self::$webcolor[$color];
|
||||
} else {
|
||||
// spot color
|
||||
$returncolor = self::getSpotColor($color, $spotc);
|
||||
if ($returncolor === false) {
|
||||
$returncolor = $defcol;
|
||||
}
|
||||
return $returncolor;
|
||||
}
|
||||
} else {
|
||||
$color_code = substr($color, 1);
|
||||
}
|
||||
// HEXADECIMAL REPRESENTATION
|
||||
switch (strlen($color_code)) {
|
||||
case 3: {
|
||||
// 3-digit RGB hexadecimal representation
|
||||
$r = substr($color_code, 0, 1);
|
||||
$g = substr($color_code, 1, 1);
|
||||
$b = substr($color_code, 2, 1);
|
||||
$returncolor = array();
|
||||
$returncolor['R'] = max(0, min(255, hexdec($r.$r)));
|
||||
$returncolor['G'] = max(0, min(255, hexdec($g.$g)));
|
||||
$returncolor['B'] = max(0, min(255, hexdec($b.$b)));
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
// 6-digit RGB hexadecimal representation
|
||||
$returncolor = array();
|
||||
$returncolor['R'] = max(0, min(255, hexdec(substr($color_code, 0, 2))));
|
||||
$returncolor['G'] = max(0, min(255, hexdec(substr($color_code, 2, 2))));
|
||||
$returncolor['B'] = max(0, min(255, hexdec(substr($color_code, 4, 2))));
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
// 8-digit CMYK hexadecimal representation
|
||||
$returncolor = array();
|
||||
$returncolor['C'] = max(0, min(100, round(hexdec(substr($color_code, 0, 2)) / 2.55)));
|
||||
$returncolor['M'] = max(0, min(100, round(hexdec(substr($color_code, 2, 2)) / 2.55)));
|
||||
$returncolor['Y'] = max(0, min(100, round(hexdec(substr($color_code, 4, 2)) / 2.55)));
|
||||
$returncolor['K'] = max(0, min(100, round(hexdec(substr($color_code, 6, 2)) / 2.55)));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$returncolor = $defcol;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $returncolor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a color array into a string representation.
|
||||
* @param $c (array) Array of colors.
|
||||
* @return (string) The color array representation.
|
||||
* @since 5.9.137 (2011-12-01)
|
||||
* @public static
|
||||
*/
|
||||
public static function getColorStringFromArray($c) {
|
||||
$c = array_values($c);
|
||||
$color = '[';
|
||||
switch (count($c)) {
|
||||
case 4: {
|
||||
// CMYK
|
||||
$color .= sprintf('%F %F %F %F', (max(0, min(100, floatval($c[0]))) / 100), (max(0, min(100, floatval($c[1]))) / 100), (max(0, min(100, floatval($c[2]))) / 100), (max(0, min(100, floatval($c[3]))) / 100));
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
// RGB
|
||||
$color .= sprintf('%F %F %F', (max(0, min(255, floatval($c[0]))) / 255), (max(0, min(255, floatval($c[1]))) / 255), (max(0, min(255, floatval($c[2]))) / 255));
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
// grayscale
|
||||
$color .= sprintf('%F', (max(0, min(255, floatval($c[0]))) / 255));
|
||||
break;
|
||||
}
|
||||
}
|
||||
$color .= ']';
|
||||
return $color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert color to javascript color.
|
||||
* @param $color (string) color name or "#RRGGBB"
|
||||
* @protected
|
||||
* @since 2.1.002 (2008-02-12)
|
||||
* @public static
|
||||
*/
|
||||
public static function _JScolor($color) {
|
||||
if (substr($color, 0, 1) == '#') {
|
||||
return sprintf("['RGB',%F,%F,%F]", (hexdec(substr($color, 1, 2)) / 255), (hexdec(substr($color, 3, 2)) / 255), (hexdec(substr($color, 5, 2)) / 255));
|
||||
}
|
||||
if (!in_array($color, self::$jscolor)) {
|
||||
// default transparent color
|
||||
$color = $jscolor[0];
|
||||
}
|
||||
return 'color.'.$color;
|
||||
}
|
||||
|
||||
|
||||
} // END OF TCPDF_COLORS CLASS
|
||||
|
||||
//============================================================+
|
||||
// END OF FILE
|
||||
//============================================================+
|
||||
481
www/analytics/libs/tcpdf/include/tcpdf_filters.php
Normal file
481
www/analytics/libs/tcpdf/include/tcpdf_filters.php
Normal file
|
|
@ -0,0 +1,481 @@
|
|||
<?php
|
||||
//============================================================+
|
||||
// File name : tcpdf_filters.php
|
||||
// Version : 1.0.001
|
||||
// Begin : 2011-05-23
|
||||
// Last Update : 2013-09-15
|
||||
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
|
||||
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
|
||||
// -------------------------------------------------------------------
|
||||
// Copyright (C) 2011-2013 Nicola Asuni - Tecnick.com LTD
|
||||
//
|
||||
// This file is part of TCPDF software library.
|
||||
//
|
||||
// TCPDF is free software: you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// TCPDF is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the License
|
||||
// along with TCPDF. If not, see
|
||||
// <http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT>.
|
||||
//
|
||||
// See LICENSE.TXT file for more information.
|
||||
// -------------------------------------------------------------------
|
||||
//
|
||||
// Description : This is a PHP class for decoding common PDF filters (PDF 32000-2008 - 7.4 Filters).
|
||||
//
|
||||
//============================================================+
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This is a PHP class for decoding common PDF filters (PDF 32000-2008 - 7.4 Filters).<br>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @author Nicola Asuni
|
||||
* @version 1.0.001
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TCPDF_FILTERS
|
||||
* This is a PHP class for decoding common PDF filters (PDF 32000-2008 - 7.4 Filters).<br>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @brief This is a PHP class for decoding common PDF filters.
|
||||
* @version 1.0.001
|
||||
* @author Nicola Asuni - info@tecnick.com
|
||||
*/
|
||||
class TCPDF_FILTERS {
|
||||
|
||||
/**
|
||||
* Define a list of available filter decoders.
|
||||
* @private static
|
||||
*/
|
||||
private static $available_filters = array('ASCIIHexDecode', 'ASCII85Decode', 'LZWDecode', 'FlateDecode', 'RunLengthDecode');
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get a list of available decoding filters.
|
||||
* @return (array) Array of available filter decoders.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function getAvailableFilters() {
|
||||
return self::$available_filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode data using the specified filter type.
|
||||
* @param $filter (string) Filter name.
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilter($filter, $data) {
|
||||
switch ($filter) {
|
||||
case 'ASCIIHexDecode': {
|
||||
return self::decodeFilterASCIIHexDecode($data);
|
||||
break;
|
||||
}
|
||||
case 'ASCII85Decode': {
|
||||
return self::decodeFilterASCII85Decode($data);
|
||||
break;
|
||||
}
|
||||
case 'LZWDecode': {
|
||||
return self::decodeFilterLZWDecode($data);
|
||||
break;
|
||||
}
|
||||
case 'FlateDecode': {
|
||||
return self::decodeFilterFlateDecode($data);
|
||||
break;
|
||||
}
|
||||
case 'RunLengthDecode': {
|
||||
return self::decodeFilterRunLengthDecode($data);
|
||||
break;
|
||||
}
|
||||
case 'CCITTFaxDecode': {
|
||||
return self::decodeFilterCCITTFaxDecode($data);
|
||||
break;
|
||||
}
|
||||
case 'JBIG2Decode': {
|
||||
return self::decodeFilterJBIG2Decode($data);
|
||||
break;
|
||||
}
|
||||
case 'DCTDecode': {
|
||||
return self::decodeFilterDCTDecode($data);
|
||||
break;
|
||||
}
|
||||
case 'JPXDecode': {
|
||||
return self::decodeFilterJPXDecode($data);
|
||||
break;
|
||||
}
|
||||
case 'Crypt': {
|
||||
return self::decodeFilterCrypt($data);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return self::decodeFilterStandard($data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- FILTERS (PDF 32000-2008 - 7.4 Filters) ------------------------------
|
||||
|
||||
/**
|
||||
* Standard
|
||||
* Default decoding filter (leaves data unchanged).
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterStandard($data) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* ASCIIHexDecode
|
||||
* Decodes data encoded in an ASCII hexadecimal representation, reproducing the original binary data.
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterASCIIHexDecode($data) {
|
||||
// intialize string to return
|
||||
$decoded = '';
|
||||
// all white-space characters shall be ignored
|
||||
$data = preg_replace('/[\s]/', '', $data);
|
||||
// check for EOD character: GREATER-THAN SIGN (3Eh)
|
||||
$eod = strpos($data, '>');
|
||||
if ($eod !== false) {
|
||||
// remove EOD and extra data (if any)
|
||||
$data = substr($data, 0, $eod);
|
||||
$eod = true;
|
||||
}
|
||||
// get data length
|
||||
$data_length = strlen($data);
|
||||
if (($data_length % 2) != 0) {
|
||||
// odd number of hexadecimal digits
|
||||
if ($eod) {
|
||||
// EOD shall behave as if a 0 (zero) followed the last digit
|
||||
$data = substr($data, 0, -1).'0'.substr($data, -1);
|
||||
} else {
|
||||
self::Error('decodeFilterASCIIHexDecode: invalid code');
|
||||
}
|
||||
}
|
||||
// check for invalid characters
|
||||
if (preg_match('/[^a-fA-F\d]/', $data) > 0) {
|
||||
self::Error('decodeFilterASCIIHexDecode: invalid code');
|
||||
}
|
||||
// get one byte of binary data for each pair of ASCII hexadecimal digits
|
||||
$decoded = pack('H*', $data);
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* ASCII85Decode
|
||||
* Decodes data encoded in an ASCII base-85 representation, reproducing the original binary data.
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterASCII85Decode($data) {
|
||||
// intialize string to return
|
||||
$decoded = '';
|
||||
// all white-space characters shall be ignored
|
||||
$data = preg_replace('/[\s]/', '', $data);
|
||||
// remove start sequence 2-character sequence <~ (3Ch)(7Eh)
|
||||
if (strpos($data, '<~') !== false) {
|
||||
// remove EOD and extra data (if any)
|
||||
$data = substr($data, 2);
|
||||
}
|
||||
// check for EOD: 2-character sequence ~> (7Eh)(3Eh)
|
||||
$eod = strpos($data, '~>');
|
||||
if ($eod !== false) {
|
||||
// remove EOD and extra data (if any)
|
||||
$data = substr($data, 0, $eod);
|
||||
}
|
||||
// data length
|
||||
$data_length = strlen($data);
|
||||
// check for invalid characters
|
||||
if (preg_match('/[^\x21-\x75,\x74]/', $data) > 0) {
|
||||
self::Error('decodeFilterASCII85Decode: invalid code');
|
||||
}
|
||||
// z sequence
|
||||
$zseq = chr(0).chr(0).chr(0).chr(0);
|
||||
// position inside a group of 4 bytes (0-3)
|
||||
$group_pos = 0;
|
||||
$tuple = 0;
|
||||
$pow85 = array((85*85*85*85), (85*85*85), (85*85), 85, 1);
|
||||
$last_pos = ($data_length - 1);
|
||||
// for each byte
|
||||
for ($i = 0; $i < $data_length; ++$i) {
|
||||
// get char value
|
||||
$char = ord($data[$i]);
|
||||
if ($char == 122) { // 'z'
|
||||
if ($group_pos == 0) {
|
||||
$decoded .= $zseq;
|
||||
} else {
|
||||
self::Error('decodeFilterASCII85Decode: invalid code');
|
||||
}
|
||||
} else {
|
||||
// the value represented by a group of 5 characters should never be greater than 2^32 - 1
|
||||
$tuple += (($char - 33) * $pow85[$group_pos]);
|
||||
if ($group_pos == 4) {
|
||||
$decoded .= chr($tuple >> 24).chr($tuple >> 16).chr($tuple >> 8).chr($tuple);
|
||||
$tuple = 0;
|
||||
$group_pos = 0;
|
||||
} else {
|
||||
++$group_pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($group_pos > 1) {
|
||||
$tuple += $pow85[($group_pos - 1)];
|
||||
}
|
||||
// last tuple (if any)
|
||||
switch ($group_pos) {
|
||||
case 4: {
|
||||
$decoded .= chr($tuple >> 24).chr($tuple >> 16).chr($tuple >> 8);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
$decoded .= chr($tuple >> 24).chr($tuple >> 16);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
$decoded .= chr($tuple >> 24);
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
self::Error('decodeFilterASCII85Decode: invalid code');
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* LZWDecode
|
||||
* Decompresses data encoded using the LZW (Lempel-Ziv-Welch) adaptive compression method, reproducing the original text or binary data.
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterLZWDecode($data) {
|
||||
// intialize string to return
|
||||
$decoded = '';
|
||||
// data length
|
||||
$data_length = strlen($data);
|
||||
// convert string to binary string
|
||||
$bitstring = '';
|
||||
for ($i = 0; $i < $data_length; ++$i) {
|
||||
$bitstring .= sprintf('%08b', ord($data{$i}));
|
||||
}
|
||||
// get the number of bits
|
||||
$data_length = strlen($bitstring);
|
||||
// initialize code length in bits
|
||||
$bitlen = 9;
|
||||
// initialize dictionary index
|
||||
$dix = 258;
|
||||
// initialize the dictionary (with the first 256 entries).
|
||||
$dictionary = array();
|
||||
for ($i = 0; $i < 256; ++$i) {
|
||||
$dictionary[$i] = chr($i);
|
||||
}
|
||||
// previous val
|
||||
$prev_index = 0;
|
||||
// while we encounter EOD marker (257), read code_length bits
|
||||
while (($data_length > 0) AND (($index = bindec(substr($bitstring, 0, $bitlen))) != 257)) {
|
||||
// remove read bits from string
|
||||
$bitstring = substr($bitstring, $bitlen);
|
||||
// update number of bits
|
||||
$data_length -= $bitlen;
|
||||
if ($index == 256) { // clear-table marker
|
||||
// reset code length in bits
|
||||
$bitlen = 9;
|
||||
// reset dictionary index
|
||||
$dix = 258;
|
||||
$prev_index = 256;
|
||||
// reset the dictionary (with the first 256 entries).
|
||||
$dictionary = array();
|
||||
for ($i = 0; $i < 256; ++$i) {
|
||||
$dictionary[$i] = chr($i);
|
||||
}
|
||||
} elseif ($prev_index == 256) {
|
||||
// first entry
|
||||
$decoded .= $dictionary[$index];
|
||||
$prev_index = $index;
|
||||
} else {
|
||||
// check if index exist in the dictionary
|
||||
if ($index < $dix) {
|
||||
// index exist on dictionary
|
||||
$decoded .= $dictionary[$index];
|
||||
$dic_val = $dictionary[$prev_index].$dictionary[$index]{0};
|
||||
// store current index
|
||||
$prev_index = $index;
|
||||
} else {
|
||||
// index do not exist on dictionary
|
||||
$dic_val = $dictionary[$prev_index].$dictionary[$prev_index]{0};
|
||||
$decoded .= $dic_val;
|
||||
}
|
||||
// update dictionary
|
||||
$dictionary[$dix] = $dic_val;
|
||||
++$dix;
|
||||
// change bit length by case
|
||||
if ($dix == 2047) {
|
||||
$bitlen = 12;
|
||||
} elseif ($dix == 1023) {
|
||||
$bitlen = 11;
|
||||
} elseif ($dix == 511) {
|
||||
$bitlen = 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* FlateDecode
|
||||
* Decompresses data encoded using the zlib/deflate compression method, reproducing the original text or binary data.
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterFlateDecode($data) {
|
||||
// intialize string to return
|
||||
$decoded = @gzuncompress($data);
|
||||
if ($decoded === false) {
|
||||
self::Error('decodeFilterFlateDecode: invalid code');
|
||||
}
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* RunLengthDecode
|
||||
* Decompresses data encoded using a byte-oriented run-length encoding algorithm.
|
||||
* @param $data (string) Data to decode.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterRunLengthDecode($data) {
|
||||
// intialize string to return
|
||||
$decoded = '';
|
||||
// data length
|
||||
$data_length = strlen($data);
|
||||
$i = 0;
|
||||
while($i < $data_length) {
|
||||
// get current byte value
|
||||
$byte = ord($data{$i});
|
||||
if ($byte == 128) {
|
||||
// a length value of 128 denote EOD
|
||||
break;
|
||||
} elseif ($byte < 128) {
|
||||
// if the length byte is in the range 0 to 127
|
||||
// the following length + 1 (1 to 128) bytes shall be copied literally during decompression
|
||||
$decoded .= substr($data, ($i + 1), ($byte + 1));
|
||||
// move to next block
|
||||
$i += ($byte + 2);
|
||||
} else {
|
||||
// if length is in the range 129 to 255,
|
||||
// the following single byte shall be copied 257 - length (2 to 128) times during decompression
|
||||
$decoded .= str_repeat($data{($i + 1)}, (257 - $byte));
|
||||
// move to next block
|
||||
$i += 2;
|
||||
}
|
||||
}
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* CCITTFaxDecode (NOT IMPLEMETED - RETURN AN EXCEPTION)
|
||||
* Decompresses data encoded using the CCITT facsimile standard, reproducing the original data (typically monochrome image data at 1 bit per pixel).
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterCCITTFaxDecode($data) {
|
||||
self::Error('~decodeFilterCCITTFaxDecode: this method has not been yet implemented');
|
||||
//return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* JBIG2Decode (NOT IMPLEMETED - RETURN AN EXCEPTION)
|
||||
* Decompresses data encoded using the JBIG2 standard, reproducing the original monochrome (1 bit per pixel) image data (or an approximation of that data).
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterJBIG2Decode($data) {
|
||||
self::Error('~decodeFilterJBIG2Decode: this method has not been yet implemented');
|
||||
//return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* DCTDecode (NOT IMPLEMETED - RETURN AN EXCEPTION)
|
||||
* Decompresses data encoded using a DCT (discrete cosine transform) technique based on the JPEG standard, reproducing image sample data that approximates the original data.
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterDCTDecode($data) {
|
||||
self::Error('~decodeFilterDCTDecode: this method has not been yet implemented');
|
||||
//return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* JPXDecode (NOT IMPLEMETED - RETURN AN EXCEPTION)
|
||||
* Decompresses data encoded using the wavelet-based JPEG2000 standard, reproducing the original image data.
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterJPXDecode($data) {
|
||||
self::Error('~decodeFilterJPXDecode: this method has not been yet implemented');
|
||||
//return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crypt (NOT IMPLEMETED - RETURN AN EXCEPTION)
|
||||
* Decrypts data encrypted by a security handler, reproducing the data as it was before encryption.
|
||||
* @param $data (string) Data to decode.
|
||||
* @return Decoded data string.
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function decodeFilterCrypt($data) {
|
||||
self::Error('~decodeFilterCrypt: this method has not been yet implemented');
|
||||
//return $data;
|
||||
}
|
||||
|
||||
// --- END FILTERS SECTION -------------------------------------------------
|
||||
|
||||
/**
|
||||
* Throw an exception.
|
||||
* @param $msg (string) The error message
|
||||
* @since 1.0.000 (2011-05-23)
|
||||
* @public static
|
||||
*/
|
||||
public static function Error($msg) {
|
||||
throw new Exception('TCPDF_PARSER ERROR: '.$msg);
|
||||
}
|
||||
|
||||
} // END OF TCPDF_FILTERS CLASS
|
||||
|
||||
//============================================================+
|
||||
// END OF FILE
|
||||
//============================================================+
|
||||
18447
www/analytics/libs/tcpdf/include/tcpdf_font_data.php
Normal file
18447
www/analytics/libs/tcpdf/include/tcpdf_font_data.php
Normal file
File diff suppressed because one or more lines are too long
2582
www/analytics/libs/tcpdf/include/tcpdf_fonts.php
Normal file
2582
www/analytics/libs/tcpdf/include/tcpdf_fonts.php
Normal file
File diff suppressed because it is too large
Load diff
355
www/analytics/libs/tcpdf/include/tcpdf_images.php
Normal file
355
www/analytics/libs/tcpdf/include/tcpdf_images.php
Normal file
|
|
@ -0,0 +1,355 @@
|
|||
<?php
|
||||
//============================================================+
|
||||
// File name : tcpdf_images.php
|
||||
// Version : 1.0.001
|
||||
// Begin : 2002-08-03
|
||||
// Last Update : 2013-08-05
|
||||
// Author : Nicola Asuni - Tecnick.com LTD - www.tecnick.com - info@tecnick.com
|
||||
// License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
|
||||
// -------------------------------------------------------------------
|
||||
// Copyright (C) 2002-2013 Nicola Asuni - Tecnick.com LTD
|
||||
//
|
||||
// This file is part of TCPDF software library.
|
||||
//
|
||||
// TCPDF is free software: you can redistribute it and/or modify it
|
||||
// under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// TCPDF is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the License
|
||||
// along with TCPDF. If not, see
|
||||
// <http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT>.
|
||||
//
|
||||
// See LICENSE.TXT file for more information.
|
||||
// -------------------------------------------------------------------
|
||||
//
|
||||
// Description :
|
||||
// Static image methods used by the TCPDF class.
|
||||
//
|
||||
//============================================================+
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This is a PHP class that contains static image methods for the TCPDF class.<br>
|
||||
* @package com.tecnick.tcpdf
|
||||
* @author Nicola Asuni
|
||||
* @version 1.0.001
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class TCPDF_IMAGES
|
||||
* Static image methods used by the TCPDF class.
|
||||
* @package com.tecnick.tcpdf
|
||||
* @brief PHP class for generating PDF documents without requiring external extensions.
|
||||
* @version 1.0.000
|
||||
* @author Nicola Asuni - info@tecnick.com
|
||||
*/
|
||||
class TCPDF_IMAGES {
|
||||
|
||||
/**
|
||||
* Array of hinheritable SVG properties.
|
||||
* @since 5.0.000 (2010-05-02)
|
||||
* @public static
|
||||
*/
|
||||
public static $svginheritprop = array('clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cursor', 'direction', 'fill', 'fill-opacity', 'fill-rule', 'font', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'image-rendering', 'kerning', 'letter-spacing', 'marker', 'marker-end', 'marker-mid', 'marker-start', 'pointer-events', 'shape-rendering', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-rendering', 'visibility', 'word-spacing', 'writing-mode');
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
/**
|
||||
* Return the image type given the file name or array returned by getimagesize() function.
|
||||
* @param $imgfile (string) image file name
|
||||
* @param $iminfo (array) array of image information returned by getimagesize() function.
|
||||
* @return string image type
|
||||
* @since 4.8.017 (2009-11-27)
|
||||
* @public static
|
||||
*/
|
||||
public static function getImageFileType($imgfile, $iminfo=array()) {
|
||||
$type = '';
|
||||
if (isset($iminfo['mime']) AND !empty($iminfo['mime'])) {
|
||||
$mime = explode('/', $iminfo['mime']);
|
||||
if ((count($mime) > 1) AND ($mime[0] == 'image') AND (!empty($mime[1]))) {
|
||||
$type = strtolower(trim($mime[1]));
|
||||
}
|
||||
}
|
||||
if (empty($type)) {
|
||||
$fileinfo = pathinfo($imgfile);
|
||||
if (isset($fileinfo['extension']) AND (!TCPDF_STATIC::empty_string($fileinfo['extension']))) {
|
||||
$type = strtolower(trim($fileinfo['extension']));
|
||||
}
|
||||
}
|
||||
if ($type == 'jpg') {
|
||||
$type = 'jpeg';
|
||||
}
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the transparency for the given GD image.
|
||||
* @param $new_image (image) GD image object
|
||||
* @param $image (image) GD image object.
|
||||
* return GD image object.
|
||||
* @since 4.9.016 (2010-04-20)
|
||||
* @public static
|
||||
*/
|
||||
public static function setGDImageTransparency($new_image, $image) {
|
||||
// transparency index
|
||||
$tid = imagecolortransparent($image);
|
||||
// default transparency color
|
||||
$tcol = array('red' => 255, 'green' => 255, 'blue' => 255);
|
||||
if ($tid >= 0) {
|
||||
// get the colors for the transparency index
|
||||
$tcol = imagecolorsforindex($image, $tid);
|
||||
}
|
||||
$tid = imagecolorallocate($new_image, $tcol['red'], $tcol['green'], $tcol['blue']);
|
||||
imagefill($new_image, 0, 0, $tid);
|
||||
imagecolortransparent($new_image, $tid);
|
||||
return $new_image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the loaded image to a PNG and then return a structure for the PDF creator.
|
||||
* This function requires GD library and write access to the directory defined on K_PATH_CACHE constant.
|
||||
* @param $image (image) Image object.
|
||||
* return image PNG image object.
|
||||
* @since 4.9.016 (2010-04-20)
|
||||
* @public static
|
||||
*/
|
||||
public static function _toPNG($image) {
|
||||
// set temporary image file name
|
||||
$tempname = TCPDF_STATIC::getObjFilename('img');
|
||||
// turn off interlaced mode
|
||||
imageinterlace($image, 0);
|
||||
// create temporary PNG image
|
||||
imagepng($image, $tempname);
|
||||
// remove image from memory
|
||||
imagedestroy($image);
|
||||
// get PNG image data
|
||||
$retvars = self::_parsepng($tempname);
|
||||
// tidy up by removing temporary image
|
||||
unlink($tempname);
|
||||
return $retvars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the loaded image to a JPEG and then return a structure for the PDF creator.
|
||||
* This function requires GD library and write access to the directory defined on K_PATH_CACHE constant.
|
||||
* @param $image (image) Image object.
|
||||
* @param $quality (int) JPEG quality.
|
||||
* return image JPEG image object.
|
||||
* @public static
|
||||
*/
|
||||
public static function _toJPEG($image, $quality) {
|
||||
$tempname = TCPDF_STATIC::getObjFilename('img');
|
||||
imagejpeg($image, $tempname, $quality);
|
||||
imagedestroy($image);
|
||||
$retvars = self::_parsejpeg($tempname);
|
||||
// tidy up by removing temporary image
|
||||
unlink($tempname);
|
||||
return $retvars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract info from a JPEG file without using the GD library.
|
||||
* @param $file (string) image file to parse
|
||||
* @return array structure containing the image data
|
||||
* @public static
|
||||
*/
|
||||
public static function _parsejpeg($file) {
|
||||
$a = getimagesize($file);
|
||||
if (empty($a)) {
|
||||
//Missing or incorrect image file
|
||||
return false;
|
||||
}
|
||||
if ($a[2] != 2) {
|
||||
// Not a JPEG file
|
||||
return false;
|
||||
}
|
||||
// bits per pixel
|
||||
$bpc = isset($a['bits']) ? intval($a['bits']) : 8;
|
||||
// number of image channels
|
||||
if (!isset($a['channels'])) {
|
||||
$channels = 3;
|
||||
} else {
|
||||
$channels = intval($a['channels']);
|
||||
}
|
||||
// default colour space
|
||||
switch ($channels) {
|
||||
case 1: {
|
||||
$colspace = 'DeviceGray';
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
$colspace = 'DeviceRGB';
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
$colspace = 'DeviceCMYK';
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
$channels = 3;
|
||||
$colspace = 'DeviceRGB';
|
||||
break;
|
||||
}
|
||||
}
|
||||
// get file content
|
||||
$data = file_get_contents($file);
|
||||
// check for embedded ICC profile
|
||||
$icc = array();
|
||||
$offset = 0;
|
||||
while (($pos = strpos($data, "ICC_PROFILE\0", $offset)) !== false) {
|
||||
// get ICC sequence length
|
||||
$length = (TCPDF_STATIC::_getUSHORT($data, ($pos - 2)) - 16);
|
||||
// marker sequence number
|
||||
$msn = max(1, ord($data[($pos + 12)]));
|
||||
// number of markers (total of APP2 used)
|
||||
$nom = max(1, ord($data[($pos + 13)]));
|
||||
// get sequence segment
|
||||
$icc[($msn - 1)] = substr($data, ($pos + 14), $length);
|
||||
// move forward to next sequence
|
||||
$offset = ($pos + 14 + $length);
|
||||
}
|
||||
// order and compact ICC segments
|
||||
if (count($icc) > 0) {
|
||||
ksort($icc);
|
||||
$icc = implode('', $icc);
|
||||
if ((ord($icc{36}) != 0x61) OR (ord($icc{37}) != 0x63) OR (ord($icc{38}) != 0x73) OR (ord($icc{39}) != 0x70)) {
|
||||
// invalid ICC profile
|
||||
$icc = false;
|
||||
}
|
||||
} else {
|
||||
$icc = false;
|
||||
}
|
||||
return array('w' => $a[0], 'h' => $a[1], 'ch' => $channels, 'icc' => $icc, 'cs' => $colspace, 'bpc' => $bpc, 'f' => 'DCTDecode', 'data' => $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract info from a PNG file without using the GD library.
|
||||
* @param $file (string) image file to parse
|
||||
* @return array structure containing the image data
|
||||
* @public static
|
||||
*/
|
||||
public static function _parsepng($file) {
|
||||
$f = @fopen($file, 'rb');
|
||||
if ($f === false) {
|
||||
// Can't open image file
|
||||
return false;
|
||||
}
|
||||
//Check signature
|
||||
if (fread($f, 8) != chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) {
|
||||
// Not a PNG file
|
||||
return false;
|
||||
}
|
||||
//Read header chunk
|
||||
fread($f, 4);
|
||||
if (fread($f, 4) != 'IHDR') {
|
||||
//Incorrect PNG file
|
||||
return false;
|
||||
}
|
||||
$w = TCPDF_STATIC::_freadint($f);
|
||||
$h = TCPDF_STATIC::_freadint($f);
|
||||
$bpc = ord(fread($f, 1));
|
||||
$ct = ord(fread($f, 1));
|
||||
if ($ct == 0) {
|
||||
$colspace = 'DeviceGray';
|
||||
} elseif ($ct == 2) {
|
||||
$colspace = 'DeviceRGB';
|
||||
} elseif ($ct == 3) {
|
||||
$colspace = 'Indexed';
|
||||
} else {
|
||||
// alpha channel
|
||||
fclose($f);
|
||||
return 'pngalpha';
|
||||
}
|
||||
if (ord(fread($f, 1)) != 0) {
|
||||
// Unknown compression method
|
||||
fclose($f);
|
||||
return false;
|
||||
}
|
||||
if (ord(fread($f, 1)) != 0) {
|
||||
// Unknown filter method
|
||||
fclose($f);
|
||||
return false;
|
||||
}
|
||||
if (ord(fread($f, 1)) != 0) {
|
||||
// Interlacing not supported
|
||||
fclose($f);
|
||||
return false;
|
||||
}
|
||||
fread($f, 4);
|
||||
$channels = ($ct == 2 ? 3 : 1);
|
||||
$parms = '/DecodeParms << /Predictor 15 /Colors '.$channels.' /BitsPerComponent '.$bpc.' /Columns '.$w.' >>';
|
||||
//Scan chunks looking for palette, transparency and image data
|
||||
$pal = '';
|
||||
$trns = '';
|
||||
$data = '';
|
||||
$icc = false;
|
||||
do {
|
||||
$n = TCPDF_STATIC::_freadint($f);
|
||||
$type = fread($f, 4);
|
||||
if ($type == 'PLTE') {
|
||||
// read palette
|
||||
$pal = TCPDF_STATIC::rfread($f, $n);
|
||||
fread($f, 4);
|
||||
} elseif ($type == 'tRNS') {
|
||||
// read transparency info
|
||||
$t = TCPDF_STATIC::rfread($f, $n);
|
||||
if ($ct == 0) {
|
||||
$trns = array(ord($t{1}));
|
||||
} elseif ($ct == 2) {
|
||||
$trns = array(ord($t{1}), ord($t{3}), ord($t{5}));
|
||||
} else {
|
||||
$pos = strpos($t, chr(0));
|
||||
if ($pos !== false) {
|
||||
$trns = array($pos);
|
||||
}
|
||||
}
|
||||
fread($f, 4);
|
||||
} elseif ($type == 'IDAT') {
|
||||
// read image data block
|
||||
$data .= TCPDF_STATIC::rfread($f, $n);
|
||||
fread($f, 4);
|
||||
} elseif ($type == 'iCCP') {
|
||||
// skip profile name
|
||||
$len = 0;
|
||||
while ((ord(fread($f, 1)) > 0) AND ($len < 80)) {
|
||||
++$len;
|
||||
}
|
||||
// skip null separator
|
||||
fread($f, 1);
|
||||
// get compression method
|
||||
if (ord(fread($f, 1)) != 0) {
|
||||
// Unknown filter method
|
||||
fclose($f);
|
||||
return false;
|
||||
}
|
||||
// read ICC Color Profile
|
||||
$icc = TCPDF_STATIC::rfread($f, ($n - $len - 2));
|
||||
// decompress profile
|
||||
$icc = gzuncompress($icc);
|
||||
fread($f, 4);
|
||||
} elseif ($type == 'IEND') {
|
||||
break;
|
||||
} else {
|
||||
TCPDF_STATIC::rfread($f, $n + 4);
|
||||
}
|
||||
} while ($n);
|
||||
if (($colspace == 'Indexed') AND (empty($pal))) {
|
||||
// Missing palette
|
||||
fclose($f);
|
||||
return false;
|
||||
}
|
||||
fclose($f);
|
||||
return array('w' => $w, 'h' => $h, 'ch' => $channels, 'icc' => $icc, 'cs' => $colspace, 'bpc' => $bpc, 'f' => 'FlateDecode', 'parms' => $parms, 'pal' => $pal, 'trns' => $trns, 'data' => $data);
|
||||
}
|
||||
|
||||
} // END OF TCPDF_IMAGES CLASS
|
||||
|
||||
//============================================================+
|
||||
// END OF FILE
|
||||
//============================================================+
|
||||
2837
www/analytics/libs/tcpdf/include/tcpdf_static.php
Normal file
2837
www/analytics/libs/tcpdf/include/tcpdf_static.php
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue