File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,19 @@ public function send($filename = null,$inline = false)
144144 return true ;
145145 }
146146
147+ /**
148+ * Get the raw Image contents (triggers Image creation).
149+ * @return string|bool The Image content as a string or `false` if the
150+ * Image wasn't created successfully.
151+ */
152+ public function toString ()
153+ {
154+ if (!$ this ->_isCreated && !$ this ->createImage ()) {
155+ return false ;
156+ }
157+ return file_get_contents ($ this ->_tmpImageFile ->getFileName ());
158+ }
159+
147160 /**
148161 * Set options
149162 *
Original file line number Diff line number Diff line change @@ -102,6 +102,21 @@ public function testCanSetPageFromUrl()
102102 unlink ($ outFile );
103103 }
104104
105+ public function testToString ()
106+ {
107+ $ outFile = $ this ->getOutFile ('png ' );
108+ $ binary = $ this ->getBinary ();
109+
110+ $ image = new Image ('<html><h1>Test</h1></html> ' );
111+ $ image ->binary = $ binary ;
112+
113+ $ this ->assertTrue ($ image ->saveAs ($ outFile ));
114+ $ this ->assertFileExists ($ outFile );
115+
116+ $ this ->assertEquals (file_get_contents ($ outFile ), $ image ->toString ());
117+ unlink ($ outFile );
118+ }
119+
105120 // Options
106121 public function testCanOptionsInConstructor ()
107122 {
You can’t perform that action at this time.
0 commit comments