Skip to content

Commit

Permalink
Update to 2.10.0. Fix PHPH 8
Browse files Browse the repository at this point in the history
  • Loading branch information
denysdesign committed Feb 1, 2023
1 parent efba993 commit 0963c3a
Show file tree
Hide file tree
Showing 6 changed files with 428 additions and 180 deletions.
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<project name="julib" default="dist" basedir=".">

<property name="VERSION" value="2.9.0"/>
<property name="VERSION" value="2.10.0"/>

<tstamp>
<format property="DATE" pattern="%d.%m.%Y" />
Expand Down
24 changes: 12 additions & 12 deletions julib/phpthumb/phpthumb.bmp.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public function getid3_bmp(&$BMPdata, &$ThisFileInfo, $ExtractPalette=false, $Ex
} else {
$paletteoffset++; // padding byte
}
$thisfile_bmp['palette'][$i] = (($red << 16) | ($green << 8) | ($blue));
$thisfile_bmp['palette'][$i] = (($red << 16) | ($green << 8) | $blue);
}
}
}
Expand All @@ -391,7 +391,7 @@ public function getid3_bmp(&$BMPdata, &$ThisFileInfo, $ExtractPalette=false, $Ex
case 1:
for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col = $col) {
$paletteindexbyte = ord($BMPpixelData{$pixeldataoffset++});
$paletteindexbyte = ord($BMPpixelData[$pixeldataoffset++]);
for ($i = 7; $i >= 0; $i--) {
$paletteindex = ($paletteindexbyte & (0x01 << $i)) >> $i;
$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindex];
Expand All @@ -408,7 +408,7 @@ public function getid3_bmp(&$BMPdata, &$ThisFileInfo, $ExtractPalette=false, $Ex
case 4:
for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col = $col) {
$paletteindexbyte = ord($BMPpixelData{$pixeldataoffset++});
$paletteindexbyte = ord($BMPpixelData[$pixeldataoffset++]);
for ($i = 1; $i >= 0; $i--) {
$paletteindex = ($paletteindexbyte & (0x0F << (4 * $i))) >> (4 * $i);
$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindex];
Expand All @@ -425,7 +425,7 @@ public function getid3_bmp(&$BMPdata, &$ThisFileInfo, $ExtractPalette=false, $Ex
case 8:
for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col++) {
$paletteindex = ord($BMPpixelData{$pixeldataoffset++});
$paletteindex = ord($BMPpixelData[$pixeldataoffset++]);
$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindex];
}
while (($pixeldataoffset % 4) != 0) {
Expand All @@ -438,7 +438,7 @@ public function getid3_bmp(&$BMPdata, &$ThisFileInfo, $ExtractPalette=false, $Ex
case 24:
for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col++) {
$thisfile_bmp['data'][$row][$col] = (ord($BMPpixelData{$pixeldataoffset+2}) << 16) | (ord($BMPpixelData{$pixeldataoffset+1}) << 8) | ord($BMPpixelData{$pixeldataoffset});
$thisfile_bmp['data'][$row][$col] = (ord($BMPpixelData[$pixeldataoffset+2]) << 16) | (ord($BMPpixelData[$pixeldataoffset+1]) << 8) | ord($BMPpixelData[$pixeldataoffset]);
$pixeldataoffset += 3;
}
while (($pixeldataoffset % 4) != 0) {
Expand All @@ -451,7 +451,7 @@ public function getid3_bmp(&$BMPdata, &$ThisFileInfo, $ExtractPalette=false, $Ex
case 32:
for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col++) {
$thisfile_bmp['data'][$row][$col] = (ord($BMPpixelData{$pixeldataoffset+3}) << 24) | (ord($BMPpixelData{$pixeldataoffset+2}) << 16) | (ord($BMPpixelData{$pixeldataoffset+1}) << 8) | ord($BMPpixelData{$pixeldataoffset});
$thisfile_bmp['data'][$row][$col] = (ord($BMPpixelData[$pixeldataoffset+3]) << 24) | (ord($BMPpixelData[$pixeldataoffset+2]) << 16) | (ord($BMPpixelData[$pixeldataoffset+1]) << 8) | ord($BMPpixelData[$pixeldataoffset]);
$pixeldataoffset += 4;
}
while (($pixeldataoffset % 4) != 0) {
Expand Down Expand Up @@ -621,7 +621,7 @@ public function getid3_bmp(&$BMPdata, &$ThisFileInfo, $ExtractPalette=false, $Ex
for ($i = 0; $i < $firstbyte; $i++) {
$col = $pixelcounter % $thisfile_bmp_header_raw['width'];
$row = $thisfile_bmp_header_raw['height'] - 1 - (($pixelcounter - $col) / $thisfile_bmp_header_raw['width']);
$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindexes[($i % 2)]];
$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][ $paletteindexes[ $i % 2 ]];
$pixelcounter++;
}

Expand Down Expand Up @@ -664,7 +664,7 @@ public function getid3_bmp(&$BMPdata, &$ThisFileInfo, $ExtractPalette=false, $Ex
$red = (int) round(((($pixelvalue & $thisfile_bmp_header_raw[ 'red_mask']) >> $redshift) / ($thisfile_bmp_header_raw[ 'red_mask'] >> $redshift)) * 255);
$green = (int) round(((($pixelvalue & $thisfile_bmp_header_raw[ 'green_mask']) >> $greenshift) / ($thisfile_bmp_header_raw[ 'green_mask'] >> $greenshift)) * 255);
$blue = (int) round(((($pixelvalue & $thisfile_bmp_header_raw[ 'blue_mask']) >> $blueshift) / ($thisfile_bmp_header_raw[ 'blue_mask'] >> $blueshift)) * 255);
$thisfile_bmp['data'][$row][$col] = (($red << 16) | ($green << 8) | ($blue));
$thisfile_bmp['data'][$row][$col] = (($red << 16) | ($green << 8) | $blue);
}
while (($pixeldataoffset % 4) != 0) {
// lines are padded to nearest DWORD
Expand Down Expand Up @@ -725,7 +725,7 @@ public function PlotPixelsGD(&$BMPdata, $truecolor=true) {
}

}
if (!is_resource($gd)) {
if (!is_resource($gd) && !(is_object($gd) && $gd instanceOf \GdImage)) {
return false;
}

Expand Down Expand Up @@ -814,7 +814,7 @@ public function LittleEndian2Int($byteword) {
$byteword = strrev($byteword);
$bytewordlen = strlen($byteword);
for ($i = 0; $i < $bytewordlen; $i++) {
$intvalue += ord($byteword{$i}) * pow(256, ($bytewordlen - 1 - $i));
$intvalue += ord($byteword[$i]) * pow(256, $bytewordlen - 1 - $i);
}
return $intvalue;
}
Expand All @@ -827,7 +827,7 @@ public function BigEndian2Bin($byteword) {
$binvalue = '';
$bytewordlen = strlen($byteword);
for ($i = 0; $i < $bytewordlen; $i++) {
$binvalue .= str_pad(decbin(ord($byteword{$i})), 8, '0', STR_PAD_LEFT);
$binvalue .= str_pad(decbin(ord($byteword[$i])), 8, '0', STR_PAD_LEFT);
}
return $binvalue;
}
Expand All @@ -840,7 +840,7 @@ public function FixedPoint2_30($rawdata) {
public function Bin2Dec($binstring, $signed=false) {
$signmult = 1;
if ($signed) {
if ($binstring{0} == '1') {
if ($binstring[0] == '1') {
$signmult = -1;
}
$binstring = substr($binstring, 1);
Expand Down
Loading

0 comments on commit 0963c3a

Please sign in to comment.