Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace resource with GdImage #326

Merged
merged 1 commit into from
Jun 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/claviska/SimpleImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
namespace claviska;

use Exception;
use GdImage;
use League\ColorExtractor\Color;
use League\ColorExtractor\ColorExtractor;
use League\ColorExtractor\Palette;
Expand Down Expand Up @@ -64,7 +65,7 @@ class SimpleImage

protected array $flags;

protected $image;
protected $image = null;

protected string $mimeType;

Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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.
Expand All @@ -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) {
Expand Down