diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 903ec58..c921a6c 100755 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,3 +1,6 @@ +5.9.209 (2013-03-15) + - Image method was improved. + 5.9.208 (2013-03-15) - objclone fuction was patched to support old imagick extensions. - tcpdf_parser was improved to support Cross-Reference Streams and large streams. diff --git a/README.TXT b/README.TXT index 00d34d0..9c33ce4 100755 --- a/README.TXT +++ b/README.TXT @@ -8,7 +8,7 @@ http://sourceforge.net/donate/index.php?group_id=128076 ------------------------------------------------------------ Name: TCPDF -Version: 5.9.208 +Version: 5.9.209 Release date: 2013-03-15 Author: Nicola Asuni diff --git a/composer.json b/composer.json index 69761c8..9bb7202 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "tecnick.com/tcpdf", - "version": "5.9.208", + "version": "5.9.209", "homepage": "http://www.tcpdf.org/", "type": "library", "description": "TCPDF is a PHP class for generating PDF documents.", diff --git a/tcpdf.php b/tcpdf.php index 67582dc..ce65f82 100755 --- a/tcpdf.php +++ b/tcpdf.php @@ -1,7 +1,7 @@ getObjFilename('img'); - $fp = fopen($file, 'w'); - fwrite($fp, $imgdata); - fclose($fp); - unset($imgdata); - $imsize = @getimagesize($file); - if ($imsize === FALSE) { - unlink($file); - } else { - $this->cached_files[] = $file; - } } else { // image file if ($file{0} === '*') { // image as external stream @@ -7989,7 +7978,7 @@ class TCPDF { // get image dimensions $imsize = @getimagesize($file); } else { - $imsize = false; + $imsize = FALSE; } if ($imsize === FALSE) { if (function_exists('curl_init')) { @@ -8009,30 +7998,27 @@ class TCPDF { curl_setopt($cs, CURLOPT_USERAGENT, 'TCPDF'); $imgdata = curl_exec($cs); curl_close($cs); - if ($imgdata !== FALSE) { - // copy image to cache - $file = $this->getObjFilename('img'); - $fp = fopen($file, 'w'); - fwrite($fp, $imgdata); - fclose($fp); - unset($imgdata); - $imsize = @getimagesize($file); - if ($imsize === FALSE) { - unlink($file); - } else { - $this->cached_files[] = $file; - } - } - } elseif (($w > 0) AND ($h > 0)) { - // get measures from specified data - $pw = $this->getHTMLUnitToUnits($w, 0, $this->pdfunit, true) * $this->imgscale * $this->k; - $ph = $this->getHTMLUnitToUnits($h, 0, $this->pdfunit, true) * $this->imgscale * $this->k; - $imsize = array($pw, $ph); + } else { + $imgdata = @file_get_contents($file); } } } + if (isset($imgdata) AND ($imgdata !== FALSE)) { + // copy image to cache + $file = $this->getObjFilename('img'); + $fp = fopen($file, 'w'); + fwrite($fp, $imgdata); + fclose($fp); + unset($imgdata); + $imsize = @getimagesize($file); + if ($imsize === FALSE) { + unlink($file); + } else { + $this->cached_files[] = $file; + } + } if ($imsize === FALSE) { - if (substr($file, 0, -34) == K_PATH_CACHE.'msk') { // mask file + if (($w > 0) AND ($h > 0)) { // get measures from specified data $pw = $this->getHTMLUnitToUnits($w, 0, $this->pdfunit, true) * $this->imgscale * $this->k; $ph = $this->getHTMLUnitToUnits($h, 0, $this->pdfunit, true) * $this->imgscale * $this->k; @@ -8247,7 +8233,7 @@ class TCPDF { } $img->setCompressionQuality($this->jpeg_quality); $img->setImageFormat('jpeg'); - $tempname = tempnam(K_PATH_CACHE, 'jpg_'); + $tempname = $this->getObjFilename('jpg'); $img->writeImage($tempname); $info = $this->_parsejpeg($tempname); unlink($tempname); @@ -8398,7 +8384,7 @@ class TCPDF { * @protected */ protected function _toJPEG($image) { - $tempname = tempnam(K_PATH_CACHE, 'jpg_'); + $tempname = $this->getObjFilename('jpg'); imagejpeg($image, $tempname, $this->jpeg_quality); imagedestroy($image); $retvars = $this->_parsejpeg($tempname); @@ -8417,7 +8403,7 @@ class TCPDF { */ protected function _toPNG($image) { // set temporary image file name - $tempname = tempnam(K_PATH_CACHE, 'jpg_'); + $tempname = $this->getObjFilename('png'); // turn off interlaced mode imageinterlace($image, 0); // create temporary PNG image @@ -9038,7 +9024,7 @@ class TCPDF { $byterange .= str_repeat(' ', ($byterange_string_len - strlen($byterange))); $pdfdoc = str_replace($this->byterange_string, $byterange, $pdfdoc); // write the document to a temporary folder - $tempdoc = tempnam(K_PATH_CACHE, 'tmppdf_'); + $tempdoc = $this->getObjFilename('tmppdf'); $f = fopen($tempdoc, 'wb'); if (!$f) { $this->Error('Unable to create temporary file: '.$tempdoc); @@ -9047,7 +9033,7 @@ class TCPDF { fwrite($f, $pdfdoc, $pdfdoc_length); fclose($f); // get digital signature via openssl library - $tempsign = tempnam(K_PATH_CACHE, 'tmpsig_'); + $tempsign = $this->getObjFilename('tmpsig'); if (empty($this->signature_data['extracerts'])) { openssl_pkcs7_sign($tempdoc, $tempsign, $this->signature_data['signcert'], array($this->signature_data['privkey'], $this->signature_data['password']), array(), PKCS7_BINARY | PKCS7_DETACHED); } else { @@ -14749,7 +14735,7 @@ class TCPDF { // envelope data $envelope = $seed.$pkpermissions; // write the envelope data to a temporary file - $tempkeyfile = tempnam(K_PATH_CACHE, 'tmpkey_'); + $tempkeyfile = $this->getObjFilename('tmpkey'); $f = fopen($tempkeyfile, 'wb'); if (!$f) { $this->Error('Unable to create temporary key file: '.$tempkeyfile); @@ -14757,7 +14743,7 @@ class TCPDF { $envelope_length = strlen($envelope); fwrite($f, $envelope, $envelope_length); fclose($f); - $tempencfile = tempnam(K_PATH_CACHE, 'tmpenc_'); + $tempencfile = $this->getObjFilename('tmpenc'); if (!openssl_pkcs7_encrypt($tempkeyfile, $tempencfile, $pubkey['c'], array(), PKCS7_BINARY | PKCS7_DETACHED)) { $this->Error('Unable to encrypt the file: '.$tempkeyfile); } @@ -25960,7 +25946,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: * @protected */ protected function getObjFilename($name) { - return tempnam(K_PATH_CACHE, $name.'_'); + return tempnam(K_PATH_CACHE, $name.'_'.$this->file_id.'_'); } /**