59 public static $svginheritprop =
array(
'clip-rule',
'color',
'color-interpolation',
'color-interpolation-filters',
'color-profile',
'color-rendering',
'cursor',
'direction',
'display',
'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');
73 if (isset($iminfo[
'mime']) AND !empty($iminfo[
'mime'])) {
74 $mime = explode(
'/', $iminfo[
'mime']);
75 if ((count($mime) > 1) AND ($mime[0] ==
'image') AND (!empty($mime[1]))) {
76 $type = strtolower(trim($mime[1]));
80 $fileinfo = pathinfo($imgfile);
82 $type = strtolower(trim($fileinfo[
'extension']));
101 $tcol =
array(
'red' => 255,
'green' => 255,
'blue' => 255);
103 $tid = imagecolortransparent($image);
104 $palletsize = imagecolorstotal($image);
105 if (($tid >= 0) AND ($tid < $palletsize)) {
107 $tcol = imagecolorsforindex($image, $tid);
109 $tid = imagecolorallocate($new_image, $tcol[
'red'], $tcol[
'green'], $tcol[
'blue']);
110 imagefill($new_image, 0, 0, $tid);
111 imagecolortransparent($new_image, $tid);
124 public static function _toPNG($image, $tempfile) {
126 imageinterlace($image, 0);
128 imagepng($image, $tempfile);
130 imagedestroy($image);
132 $retvars = self::_parsepng($tempfile);
147 public static function _toJPEG($image, $quality, $tempfile) {
148 imagejpeg($image, $tempfile, $quality);
149 imagedestroy($image);
150 $retvars = self::_parsejpeg($tempfile);
164 if (!@file_exists(
$file)) {
166 $tfile = str_replace(
' ',
'%20',
$file);
167 if (@file_exists($tfile)) {
171 $a = getimagesize(
$file);
181 $bpc = isset($a[
'bits']) ? intval($a[
'bits']) : 8;
183 if (!isset($a[
'channels'])) {
186 $channels = intval($a[
'channels']);
191 $colspace =
'DeviceGray';
195 $colspace =
'DeviceRGB';
199 $colspace =
'DeviceCMYK';
204 $colspace =
'DeviceRGB';
213 while (($pos = strpos(
$data,
"ICC_PROFILE\0", $offset)) !==
false) {
217 $msn = max(1, ord(
$data[($pos + 12)]));
219 $nom = max(1, ord(
$data[($pos + 13)]));
221 $icc[($msn - 1)] = substr(
$data, ($pos + 14), $length);
223 $offset = ($pos + 14 + $length);
226 if (count($icc) > 0) {
228 $icc = implode(
'', $icc);
229 if ((ord($icc[36]) != 0x61) OR (ord($icc[37]) != 0x63) OR (ord($icc[38]) != 0x73) OR (ord($icc[39]) != 0x70)) {
236 return array(
'w' => $a[0],
'h' => $a[1],
'ch' => $channels,
'icc' => $icc,
'cs' => $colspace,
'bpc' => $bpc,
'f' =>
'DCTDecode',
'data' =>
$data);
246 $f = @fopen(
$file,
'rb');
252 if (fread($f, 8) != chr(137).
'PNG'.chr(13).chr(10).chr(26).chr(10)) {
258 if (fread($f, 4) !=
'IHDR') {
264 $bpc = ord(fread($f, 1));
265 $ct = ord(fread($f, 1));
267 $colspace =
'DeviceGray';
268 } elseif ($ct == 2) {
269 $colspace =
'DeviceRGB';
270 } elseif ($ct == 3) {
271 $colspace =
'Indexed';
277 if (ord(fread($f, 1)) != 0) {
282 if (ord(fread($f, 1)) != 0) {
287 if (ord(fread($f, 1)) != 0) {
293 $channels = ($ct == 2 ? 3 : 1);
294 $parms =
'/DecodeParms << /Predictor 15 /Colors '.$channels.
' /BitsPerComponent '.$bpc.
' /Columns '.
$w.
' >>';
302 $type = fread($f, 4);
303 if ($type ==
'PLTE') {
307 } elseif ($type ==
'tRNS') {
312 } elseif ($ct == 2) {
317 for ($i = 0; $i <
$n; ++ $i) {
318 $trns[] = ord(
$t{$i});
323 } elseif ($type ==
'IDAT') {
327 } elseif ($type ==
'iCCP') {
330 while ((ord(fread($f, 1)) != 0) AND ($len < 80)) {
334 if (ord(fread($f, 1)) != 0) {
342 $icc = gzuncompress($icc);
344 } elseif ($type ==
'IEND') {
351 if (($colspace ==
'Indexed') AND (empty($pal))) {
357 return array(
'w' =>
$w,
'h' =>
$h,
'ch' => $channels,
'icc' => $icc,
'cs' => $colspace,
'bpc' => $bpc,
'f' =>
'FlateDecode',
'parms' => $parms,
'pal' => $pal,
'trns' => $trns,
'data' =>
$data);
static _parsepng($file)
Extract info from a PNG file without using the GD library.
static rfread($handle, $length)
Binary-safe and URL-safe file read.
static setGDImageTransparency($new_image, $image)
Set the transparency for the given GD image.
static empty_string($str)
Determine whether a string is empty.
static _freadint($f)
Read a 4-byte (32 bit) integer from file.
Create styles array
The data for the language used.
static _getUSHORT($str, $offset)
Get USHORT from string (Big Endian 16-bit unsigned integer).
static $svginheritprop
Array of hinheritable SVG properties.
Static image methods used by the TCPDF class.
static _toJPEG($image, $quality, $tempfile)
Convert the loaded image to a JPEG and then return a structure for the PDF creator.
static getImageFileType($imgfile, $iminfo=array())
Return the image type given the file name or array returned by getimagesize() function.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
static _parsejpeg($file)
Extract info from a JPEG file without using the GD library.
static _toPNG($image, $tempfile)
Convert the loaded image to a PNG and then return a structure for the PDF creator.