Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
brianteeman committed Sep 26, 2023
1 parent 4e99804 commit 8ff0ef3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
16 changes: 6 additions & 10 deletions libraries/src/Image/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ public function __construct($source = null)
static::$formats[IMAGETYPE_WEBP] = $info['WebP Support'];
}

// If the source input is a resource, set it as the image handle.
if (\is_resource($source) && get_resource_type($source) == 'gd') {
/**
* If the source input is a resource, set it as the image handle.
*/
if ($source && (\is_object($source) && get_class($source) == 'GdImage')) {
$this->handle = $source;
} elseif (!empty($source) && \is_string($source)) {
// If the source input is not empty, assume it is a path and populate the image handle.
Expand Down Expand Up @@ -536,14 +538,8 @@ public function getPath()
*/
public function isLoaded()
{
/**
* Make sure the resource handle is valid.
* @todo: Remove check for resource when we only support PHP 8
*/
if (
!((\is_object($this->handle) && get_class($this->handle) == 'GdImage')
|| (\is_resource($this->handle) && get_resource_type($this->handle) == 'gd'))
) {
// Make sure the resource handle is valid.
if (!(\is_object($this->handle) && get_class($this->handle) == 'GdImage')) {
return false;
}

Expand Down
5 changes: 5 additions & 0 deletions libraries/src/Image/ImageFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public function __construct($handle)
throw new \RuntimeException('The imagefilter function for PHP is not available.');
}

// Make sure the file handle is valid.
if (!(\is_object($handle) && get_class($handle) == 'GdImage')) {
throw new \InvalidArgumentException('The image handle is invalid for the image filter.');
}

$this->handle = $handle;
}

Expand Down

0 comments on commit 8ff0ef3

Please sign in to comment.