Skip to content

Commit

Permalink
Merge pull request #751 from lstrojny/bugfix/exif-invalid-values
Browse files Browse the repository at this point in the history
Ignore invalid exif orientations
  • Loading branch information
lsmith77 authored Jul 15, 2016
2 parents 3cf8a3a + c97a83d commit 53f2307
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 1 addition & 3 deletions Imagine/Filter/Loader/AutoRotateFilterLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ public function load(ImageInterface $image, array $options = array())
{
if ($orientation = $this->getOrientation($image)) {
if ($orientation < 1 || $orientation > 8) {
throw new InvalidArgumentException(
sprintf('The image has wrong EXIF orientation tag (%d)', $orientation)
);
return $image;
}

// Rotates if necessary.
Expand Down
12 changes: 8 additions & 4 deletions Tests/Imagine/Filter/Loader/AutoRotateFilterLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,16 @@ public function testLoadExif8()
/**
* Theoretically Orientation is `short` (uint16), so it could be anything
* from [0; 65535].
*
* @expectedException \Imagine\Exception\InvalidArgumentException
*/
public function testLoadExifInvalid()
public static function getInvalidOrientations()
{
return array(array(0, 9, 255, 65535));
}

/** @dataProvider getInvalidOrientations */
public function testLoadExifInvalid($orientation)
{
$this->loadExif('10', null, false);
$this->loadExif($orientation, null, false);
}

/**
Expand Down

0 comments on commit 53f2307

Please sign in to comment.