1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-10 08:44:46 +02:00

Add PR #163 small fixes in PWPNG class

Co-authored-by: horst-n <info@nogajski.de>
This commit is contained in:
Ryan Cramer
2021-05-07 14:57:29 -04:00
parent b7d8ae37e3
commit 1a71b77010

View File

@@ -25,7 +25,7 @@ class PWPNG {
public function loadFile($lpszFileName) {
// READ FILE
if(!($fh = @fopen($lpszFileName, 'rb'))) {
$this->Error('Can\'t open image file: '.$file);
$this->Error('Can\'t open image file: '.basename($lpszFileName));
return false;
}
$ret = (false === $this->_parsepngstream($fh, basename($lpszFileName))) ? false : true;
@@ -59,6 +59,7 @@ class PWPNG {
$colspace = 'Indexed';
} else {
$this->Error('Unknown color type: '.$file);
$colspace = '';
}
if(ord($this->_readstream($f, 1)) != 0) $this->Error('Unknown compression method: '.$file);
if(ord($this->_readstream($f, 1)) != 0) $this->Error('Unknown filter method: '.$file);
@@ -114,7 +115,7 @@ class PWPNG {
'channels' => $ct,
'bits' => $bpc,
'dp' => $dp,
'palette' => utf8_encode($pal),
'palette' => (function_exists('utf8_encode') ? utf8_encode($pal) : $pal),
'trans' => $trns,
'alpha' => $ct >= 4 ? true : false,
'interlace' => $interlaced,
@@ -131,7 +132,7 @@ class PWPNG {
$s = fread($f, $n);
if($s === false) {
$this->Error('Error while reading stream');
return;
return '';
}
$n -= strlen($s);
$res .= $s;