1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-31 17:41:58 +02:00

Store and expose result of latest encoded image.

This commit is contained in:
JrSchild
2013-12-12 10:21:06 +01:00
parent 4956f25b68
commit efb2f2cdc5
2 changed files with 17 additions and 2 deletions

View File

@@ -83,6 +83,14 @@ class Image
*/ */
public $cached = false; public $cached = false;
/**
* Result of image after encoding
*
* @var string
*/
public $encoded;
/** /**
* Create a new instance of Image class * Create a new instance of Image class
* *
@@ -1441,11 +1449,11 @@ class Image
break; break;
} }
$data = ob_get_contents(); $this->encoded = ob_get_contents();
ob_end_clean(); ob_end_clean();
return $data; return $this->encoded;
} }
/** /**

View File

@@ -1748,4 +1748,11 @@ class ImageTest extends PHPUnit_Framework_Testcase
$this->assertEquals('#00aef0', $img->pickColor(6, 6, 'hex')); $this->assertEquals('#00aef0', $img->pickColor(6, 6, 'hex'));
$this->assertEquals('#f6a609', $img->pickColor(11, 25, '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());
}
} }