Skip to content

Commit b25690f

Browse files
authored
replace resource with GdImage (#326)
fixes #325
1 parent e3d4c8c commit b25690f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/claviska/SimpleImage.php

+6-8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
namespace claviska;
1818

1919
use Exception;
20+
use GdImage;
2021
use League\ColorExtractor\Color;
2122
use League\ColorExtractor\ColorExtractor;
2223
use League\ColorExtractor\Palette;
@@ -64,7 +65,7 @@ class SimpleImage
6465

6566
protected array $flags;
6667

67-
protected $image;
68+
protected $image = null;
6869

6970
protected string $mimeType;
7071

@@ -115,10 +116,7 @@ public function __construct(string $image = '', array $flags = [])
115116
*/
116117
public function __destruct()
117118
{
118-
//Check for a valid GDimage instance
119-
$type_check = (gettype($this->image) == 'object' && $this->image::class == 'GdImage');
120-
121-
if (is_resource($this->image) && $type_check) {
119+
if ($this->image instanceof GdImage) {
122120
imagedestroy($this->image);
123121
}
124122
}
@@ -650,8 +648,8 @@ public function getWidth(): int
650648
/**
651649
* Same as PHP's imagecopymerge, but works with transparent images. Used internally for overlay.
652650
*
653-
* @param resource $dstIm Destination image link resource.
654-
* @param resource $srcIm Source image link resource.
651+
* @param GdImage $dstIm Destination image.
652+
* @param GdImage $srcIm Source image.
655653
* @param int $dstX x-coordinate of destination point.
656654
* @param int $dstY y-coordinate of destination point.
657655
* @param int $srcX x-coordinate of source point.
@@ -660,7 +658,7 @@ public function getWidth(): int
660658
* @param int $srcH Source height.
661659
* @return bool true if success.
662660
*/
663-
protected static function imageCopyMergeAlpha($dstIm, $srcIm, int $dstX, int $dstY, int $srcX, int $srcY, int $srcW, int $srcH, int $pct): bool
661+
protected static function imageCopyMergeAlpha(GdImage $dstIm, GdImage $srcIm, int $dstX, int $dstY, int $srcX, int $srcY, int $srcW, int $srcH, int $pct): bool
664662
{
665663
// Are we merging with transparency?
666664
if ($pct < 100) {

0 commit comments

Comments
 (0)