From efb2f2cdc5aa6b3cd55b617bd44e503685c1ffb3 Mon Sep 17 00:00:00 2001 From: JrSchild Date: Thu, 12 Dec 2013 10:21:06 +0100 Subject: [PATCH] Store and expose result of latest encoded image. --- src/Intervention/Image/Image.php | 12 ++++++++++-- tests/ImageTest.php | 7 +++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Intervention/Image/Image.php b/src/Intervention/Image/Image.php index ff992abb..2c4d011f 100644 --- a/src/Intervention/Image/Image.php +++ b/src/Intervention/Image/Image.php @@ -83,6 +83,14 @@ class Image */ public $cached = false; + /** + * Result of image after encoding + * + * @var string + */ + public $encoded; + + /** * Create a new instance of Image class * @@ -1441,11 +1449,11 @@ class Image break; } - $data = ob_get_contents(); + $this->encoded = ob_get_contents(); ob_end_clean(); - return $data; + return $this->encoded; } /** diff --git a/tests/ImageTest.php b/tests/ImageTest.php index b3015674..daa600e5 100644 --- a/tests/ImageTest.php +++ b/tests/ImageTest.php @@ -1748,4 +1748,11 @@ class ImageTest extends PHPUnit_Framework_Testcase $this->assertEquals('#00aef0', $img->pickColor(6, 6, 'hex')); $this->assertEquals('#f6a609', $img->pickColor(11, 25, 'hex')); } + + public function testEncoded() + { + $img = Image::make('public/test.jpg'); + $img->encode(); + $this->assertEquals($img->encoded, $img->encode()); + } }