public function __destruct() { if ($this->image instanceof Imagick) { // we don't need the original in memory anymore $this->image->clear(); $this->image->destroy(); } }