diff --git a/src/claviska/SimpleImage.php b/src/claviska/SimpleImage.php
index <HASH>..<HASH> 100644
--- a/src/claviska/SimpleImage.php
+++ b/src/claviska/SimpleImage.php
@@ -69,7 +69,7 @@ class SimpleImage {
    * Destroys the image resource.
    */
   public function __destruct() {
-    if($this->image !== null && get_resource_type($this->image) === 'gd') {
+    if($this->image !== null && is_resource($this->image) && get_resource_type($this->image) === 'gd') {
       imagedestroy($this->image);
     }
   }
Add support to PHP8  (#<I>)

* Add support to PHP8



In PHP8 GD has changed, uses "object" and no longer "resource".

To be compatible for both PHP7 and PHP8, I propose this change.



* Update SimpleImage.php



* Update SimpleImage.php