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

added destroy method

This commit is contained in:
Oliver Vogel
2014-02-13 15:41:08 +01:00
parent 6fd584686f
commit 18f50ac431
2 changed files with 19 additions and 1 deletions

View File

@@ -72,7 +72,7 @@ class Image
/**
* Attributes of the original created image
*
* @var Array
* @var resource
*/
protected $original;
@@ -1890,6 +1890,17 @@ class Image
return $this->encoded;
}
/**
* Destroys image resource and frees memory
*
* @return void
*/
public function destroy()
{
is_resource($this->resource) ? imagedestroy($this->resource) : null;
is_resource($this->original) ? imagedestroy($this->original) : null;
}
/**
* Returns image stream
*

View File

@@ -1784,4 +1784,11 @@ class ImageTest extends PHPUnit_Framework_Testcase
$img->encode();
$this->assertEquals($img->encoded, $img->encode());
}
public function testDestroy()
{
$img = $this->getTestImage();
$img->destroy();
$this->assertEquals(get_resource_type($img->resource), 'Unknown');
}
}