diff --git a/src/Intervention/Image/Commands/ExifCommand.php b/src/Intervention/Image/Commands/ExifCommand.php index cbea0f69..2e3dfded 100644 --- a/src/Intervention/Image/Commands/ExifCommand.php +++ b/src/Intervention/Image/Commands/ExifCommand.php @@ -22,7 +22,9 @@ class ExifCommand extends AbstractCommand } $key = $this->argument(0)->value(); - $data = exif_read_data($image->dirname .'/'. $image->basename, 'EXIF', false); + + // try to read exif data from image file + $data = @exif_read_data($image->dirname .'/'. $image->basename, 'EXIF', false); if (! is_null($key) && is_array($data)) { $data = array_key_exists($key, $data) ? $data[$key] : false; diff --git a/tests/ExifCommandTest.php b/tests/ExifCommandTest.php index edfeba38..80996f08 100644 --- a/tests/ExifCommandTest.php +++ b/tests/ExifCommandTest.php @@ -44,4 +44,26 @@ class ExifCommandTest extends PHPUnit_Framework_TestCase $this->assertTrue($command->hasOutput()); $this->assertEquals(null, $command->getOutput()); } + + public function testFetchFromPng() + { + $image = Mockery::mock('Intervention\Image\Image'); + $image->dirname = __DIR__.'/images'; + $image->basename = 'star.png'; + $command = new ExifCommand(array('Orientation')); + $result = $command->execute($image); + $this->assertTrue($result); + $this->assertTrue($command->hasOutput()); + $this->assertEquals(null, $command->getOutput()); + } + + public function testReturnNullOnExifReadFail() + { + $image = Mockery::mock('Intervention\Image\Image'); + $command = new ExifCommand(array('Orientation')); + $result = $command->execute($image); + $this->assertTrue($result); + $this->assertTrue($command->hasOutput()); + $this->assertEquals(null, $command->getOutput()); + } } diff --git a/tests/OrientateCommandTest.php b/tests/OrientateCommandTest.php index e718346e..6b86c23f 100644 --- a/tests/OrientateCommandTest.php +++ b/tests/OrientateCommandTest.php @@ -81,4 +81,13 @@ class OrientateCommandTest extends PHPUnit_Framework_TestCase $result = $command->execute($image); $this->assertTrue($result); } + + public function testExecuteOrientationNoExifData() + { + $image = Mockery::mock('Intervention\Image\Image'); + $image->shouldReceive('exif')->with('Orientation')->once()->andReturn(null); + $command = new OrientateCommand(array()); + $result = $command->execute($image); + $this->assertTrue($result); + } }