Skip to content

Commit 5d0b1a7

Browse files
committed
Fix compatibility with ext-gd on php 8
1 parent e10c01d commit 5d0b1a7

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
3535
- Fix for issue [#1735](https://github.com/PHPOffice/PhpSpreadsheet/issues/1735) Incorrect activeSheetIndex after RemoveSheetByIndex - [PR #1743](https://github.com/PHPOffice/PhpSpreadsheet/pull/1743)
3636
- Ensure that the list of shared formulae is maintained when an xlsx file is chunked with readFilter[Issue #169](https://github.com/PHPOffice/PhpSpreadsheet/issues/1669).
3737
- Fix for notice during accessing "cached magnification factor" offset [#1354](https://github.com/PHPOffice/PhpSpreadsheet/pull/1354)
38+
- Fix compatibility with ext-gd on php 8
3839

3940
### Security Fix (CVE-2020-7776)
4041

src/PhpSpreadsheet/Shared/Drawing.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace PhpOffice\PhpSpreadsheet\Shared;
44

5+
use GdImage;
6+
57
class Drawing
68
{
79
/**
@@ -152,7 +154,7 @@ public static function angleToDegrees($pValue)
152154
*
153155
* @param string $p_sFile Path to Windows DIB (BMP) image
154156
*
155-
* @return resource
157+
* @return GdImage|resource
156158
*/
157159
public static function imagecreatefrombmp($p_sFile)
158160
{

src/PhpSpreadsheet/Worksheet/MemoryDrawing.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace PhpOffice\PhpSpreadsheet\Worksheet;
44

5+
use GdImage;
6+
57
class MemoryDrawing extends BaseDrawing
68
{
79
// Rendering functions
@@ -19,7 +21,7 @@ class MemoryDrawing extends BaseDrawing
1921
/**
2022
* Image resource.
2123
*
22-
* @var resource
24+
* @var GdImage|resource
2325
*/
2426
private $imageResource;
2527

@@ -62,7 +64,7 @@ public function __construct()
6264
/**
6365
* Get image resource.
6466
*
65-
* @return resource
67+
* @return GdImage|resource
6668
*/
6769
public function getImageResource()
6870
{
@@ -72,7 +74,7 @@ public function getImageResource()
7274
/**
7375
* Set image resource.
7476
*
75-
* @param resource $value
77+
* @param GdImage|resource $value
7678
*
7779
* @return $this
7880
*/

src/PhpSpreadsheet/Writer/Xls/Worksheet.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace PhpOffice\PhpSpreadsheet\Writer\Xls;
44

5+
use GdImage;
56
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
67
use PhpOffice\PhpSpreadsheet\Cell\DataType;
78
use PhpOffice\PhpSpreadsheet\Cell\DataValidation;
@@ -2254,7 +2255,7 @@ private function writePassword(): void
22542255
*/
22552256
public function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1): void
22562257
{
2257-
$bitmap_array = (is_resource($bitmap) ? $this->processBitmapGd($bitmap) : $this->processBitmap($bitmap));
2258+
$bitmap_array = (is_resource($bitmap) || $bitmap instanceof GdImage ? $this->processBitmapGd($bitmap) : $this->processBitmap($bitmap));
22582259
[$width, $height, $size, $data] = $bitmap_array;
22592260

22602261
// Scale the frame of the image.
@@ -2460,7 +2461,7 @@ private function writeObjPicture($colL, $dxL, $rwT, $dyT, $colR, $dxR, $rwB, $dy
24602461
/**
24612462
* Convert a GD-image into the internal format.
24622463
*
2463-
* @param resource $image The image to process
2464+
* @param GdImage|resource $image The image to process
24642465
*
24652466
* @return array Array with data and properties of the bitmap
24662467
*/

0 commit comments

Comments
 (0)