From 7661edeaed0c39b257498d17aac15dd74328684d Mon Sep 17 00:00:00 2001 From: Danny Loomeijer Date: Mon, 9 Mar 2015 11:50:58 +0100 Subject: [PATCH] lowered the resource usage of GetSizeCommand() which fixes some odd Imagick segfaults --- src/Intervention/Image/Imagick/Commands/GetSizeCommand.php | 7 ++++--- tests/GetsizeCommandTest.php | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Intervention/Image/Imagick/Commands/GetSizeCommand.php b/src/Intervention/Image/Imagick/Commands/GetSizeCommand.php index 73f712fa..f0c09af6 100644 --- a/src/Intervention/Image/Imagick/Commands/GetSizeCommand.php +++ b/src/Intervention/Image/Imagick/Commands/GetSizeCommand.php @@ -14,11 +14,12 @@ class GetSizeCommand extends \Intervention\Image\Commands\AbstractCommand */ public function execute($image) { - $info = $image->getCore()->identifyImage(); + /** @var \Imagick $core */ + $core = $image->getCore(); $this->setOutput(new Size( - $info['geometry']['width'], - $info['geometry']['height'] + $core->getImageWidth(), + $core->getImageHeight() )); return true; diff --git a/tests/GetsizeCommandTest.php b/tests/GetsizeCommandTest.php index dc5e96e9..3efffa95 100644 --- a/tests/GetsizeCommandTest.php +++ b/tests/GetsizeCommandTest.php @@ -9,7 +9,7 @@ class GetSizeCommandTest extends PHPUnit_Framework_TestCase { Mockery::close(); } - + public function testGd() { $resource = imagecreatefromjpeg(__DIR__.'/images/test.jpg'); @@ -25,7 +25,8 @@ class GetSizeCommandTest extends PHPUnit_Framework_TestCase public function testImagick() { $imagick = Mockery::mock('Imagick'); - $imagick->shouldReceive('identifyimage')->with(); + $imagick->shouldReceive('getimagewidth')->with(); + $imagick->shouldReceive('getimageheight')->with(); $image = Mockery::mock('Intervention\Image\Image'); $image->shouldReceive('getCore')->once()->andReturn($imagick); $command = new GetSizeImagick(array());