@ini_set('gd.jpeg_ignore_warning', '1');
}
+ /**
+ * Returns whether the given image is a valid GD resource / GD object
+ *
+ * @return boolean
+ */
+ public function isImage($image) {
+ return (is_resource($image) && get_resource_type($image) === 'gd') || (is_object($image) && $image instanceof \GdImage);
+ }
+
/**
* @inheritDoc
*/
public function load($image, $type = '') {
- if (!is_resource($image)) {
+ if (!$this->isImage($image)) {
throw new SystemException("Image resource is invalid.");
}
* @inheritDoc
*/
public function writeImage($image, $filename) {
- if (!is_resource($image)) {
+ if (!$this->isImage($image)) {
throw new SystemException("Given image is not a valid image resource.");
}
* @param integer $pct opacity percent
* @return boolean
*/
- private function imagecopymerge_alpha($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct) {
+ private function imagecopymerge_alpha($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct) { // phpcs:ignore
if (!isset($pct)) {
return false;
}