mirror of
https://github.com/Intervention/image.git
synced 2025-09-01 18:02:45 +02:00
added destroy method
This commit is contained in:
@@ -72,7 +72,7 @@ class Image
|
|||||||
/**
|
/**
|
||||||
* Attributes of the original created image
|
* Attributes of the original created image
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var resource
|
||||||
*/
|
*/
|
||||||
protected $original;
|
protected $original;
|
||||||
|
|
||||||
@@ -1890,6 +1890,17 @@ class Image
|
|||||||
return $this->encoded;
|
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
|
* Returns image stream
|
||||||
*
|
*
|
||||||
|
@@ -1784,4 +1784,11 @@ class ImageTest extends PHPUnit_Framework_Testcase
|
|||||||
$img->encode();
|
$img->encode();
|
||||||
$this->assertEquals($img->encoded, $img->encode());
|
$this->assertEquals($img->encoded, $img->encode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDestroy()
|
||||||
|
{
|
||||||
|
$img = $this->getTestImage();
|
||||||
|
$img->destroy();
|
||||||
|
$this->assertEquals(get_resource_type($img->resource), 'Unknown');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user