17
17
namespace claviska ;
18
18
19
19
use Exception ;
20
+ use GdImage ;
20
21
use League \ColorExtractor \Color ;
21
22
use League \ColorExtractor \ColorExtractor ;
22
23
use League \ColorExtractor \Palette ;
@@ -64,7 +65,7 @@ class SimpleImage
64
65
65
66
protected array $ flags ;
66
67
67
- protected $ image ;
68
+ protected $ image = null ;
68
69
69
70
protected string $ mimeType ;
70
71
@@ -115,10 +116,7 @@ public function __construct(string $image = '', array $flags = [])
115
116
*/
116
117
public function __destruct ()
117
118
{
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) {
122
120
imagedestroy ($ this ->image );
123
121
}
124
122
}
@@ -650,8 +648,8 @@ public function getWidth(): int
650
648
/**
651
649
* Same as PHP's imagecopymerge, but works with transparent images. Used internally for overlay.
652
650
*
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.
655
653
* @param int $dstX x-coordinate of destination point.
656
654
* @param int $dstY y-coordinate of destination point.
657
655
* @param int $srcX x-coordinate of source point.
@@ -660,7 +658,7 @@ public function getWidth(): int
660
658
* @param int $srcH Source height.
661
659
* @return bool true if success.
662
660
*/
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
664
662
{
665
663
// Are we merging with transparency?
666
664
if ($ pct < 100 ) {
0 commit comments