diff --git a/src/Image.php b/src/Image.php index 2d8b4b6..1bf25e4 100644 --- a/src/Image.php +++ b/src/Image.php @@ -144,6 +144,19 @@ public function send($filename = null,$inline = false) return true; } + /** + * Get the raw Image contents (triggers Image creation). + * @return string|bool The Image content as a string or `false` if the + * Image wasn't created successfully. + */ + public function toString() + { + if (!$this->_isCreated && !$this->createImage()) { + return false; + } + return file_get_contents($this->_tmpImageFile->getFileName()); + } + /** * Set options * diff --git a/tests/ImageTest.php b/tests/ImageTest.php index 34d2f24..27f2418 100644 --- a/tests/ImageTest.php +++ b/tests/ImageTest.php @@ -102,6 +102,21 @@ public function testCanSetPageFromUrl() unlink($outFile); } + public function testToString() + { + $outFile = $this->getOutFile('png'); + $binary = $this->getBinary(); + + $image = new Image('