public function __destruct() { if (is_resource($this->_image)) { // Free all resources imagedestroy($this->_image); } }