diff --git a/src/claviska/SimpleImage.php b/src/claviska/SimpleImage.php index 23324f6..98a8232 100644 --- a/src/claviska/SimpleImage.php +++ b/src/claviska/SimpleImage.php @@ -17,6 +17,7 @@ namespace claviska; use Exception; +use GdImage; use League\ColorExtractor\Color; use League\ColorExtractor\ColorExtractor; use League\ColorExtractor\Palette; @@ -64,7 +65,7 @@ class SimpleImage protected array $flags; - protected $image; + protected $image = null; protected string $mimeType; @@ -115,10 +116,7 @@ public function __construct(string $image = '', array $flags = []) */ public function __destruct() { - //Check for a valid GDimage instance - $type_check = (gettype($this->image) == 'object' && $this->image::class == 'GdImage'); - - if (is_resource($this->image) && $type_check) { + if ($this->image instanceof GdImage) { imagedestroy($this->image); } } @@ -650,8 +648,8 @@ public function getWidth(): int /** * Same as PHP's imagecopymerge, but works with transparent images. Used internally for overlay. * - * @param resource $dstIm Destination image link resource. - * @param resource $srcIm Source image link resource. + * @param GdImage $dstIm Destination image. + * @param GdImage $srcIm Source image. * @param int $dstX x-coordinate of destination point. * @param int $dstY y-coordinate of destination point. * @param int $srcX x-coordinate of source point. @@ -660,7 +658,7 @@ public function getWidth(): int * @param int $srcH Source height. * @return bool true if success. */ - protected static function imageCopyMergeAlpha($dstIm, $srcIm, int $dstX, int $dstY, int $srcX, int $srcY, int $srcW, int $srcH, int $pct): bool + protected static function imageCopyMergeAlpha(GdImage $dstIm, GdImage $srcIm, int $dstX, int $dstY, int $srcX, int $srcY, int $srcW, int $srcH, int $pct): bool { // Are we merging with transparency? if ($pct < 100) {