Skip to content

Commit

Permalink
Add tests for EXIF data reading
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Oct 5, 2023
1 parent d317c47 commit f15a309
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
17 changes: 14 additions & 3 deletions tests/Drivers/Gd/Decoders/BinaryImageDecoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class BinaryImageDecoderTest extends TestCase
public function testDecodePng(): void
{
$decoder = new BinaryImageDecoder();
$image = $decoder->decode(file_get_contents(__DIR__ . '/../../../images/tile.png'));
$image = $decoder->decode(file_get_contents($this->getTestImagePath('tile.png')));
$this->assertInstanceOf(Image::class, $image);
$this->assertEquals(16, $image->getWidth());
$this->assertEquals(16, $image->getHeight());
Expand All @@ -25,7 +25,7 @@ public function testDecodePng(): void
public function testDecodeGif(): void
{
$decoder = new BinaryImageDecoder();
$image = $decoder->decode(file_get_contents(__DIR__ . '/../../../images/red.gif'));
$image = $decoder->decode(file_get_contents($this->getTestImagePath('red.gif')));
$this->assertInstanceOf(Image::class, $image);
$this->assertEquals(16, $image->getWidth());
$this->assertEquals(16, $image->getHeight());
Expand All @@ -35,10 +35,21 @@ public function testDecodeGif(): void
public function testDecodeAnimatedGif(): void
{
$decoder = new BinaryImageDecoder();
$image = $decoder->decode(file_get_contents(__DIR__ . '/../../../images/cats.gif'));
$image = $decoder->decode(file_get_contents($this->getTestImagePath('cats.gif')));
$this->assertInstanceOf(Image::class, $image);
$this->assertEquals(75, $image->getWidth());
$this->assertEquals(50, $image->getHeight());
$this->assertCount(4, $image);
}

public function testDecodeJpegWithExif(): void
{
$decoder = new BinaryImageDecoder();
$image = $decoder->decode(file_get_contents($this->getTestImagePath('exif.jpg')));
$this->assertInstanceOf(Image::class, $image);
$this->assertEquals(16, $image->getWidth());
$this->assertEquals(16, $image->getHeight());
$this->assertCount(1, $image);
$this->assertEquals('Oliver Vogel', $image->getExif('IFD0.Artist'));
}
}
17 changes: 14 additions & 3 deletions tests/Drivers/Imagick/Decoders/BinaryImageDecoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BinaryImageDecoderTest extends TestCase
public function testDecodePng(): void
{
$decoder = new BinaryImageDecoder();
$image = $decoder->decode(file_get_contents(__DIR__ . '/../../../images/tile.png'));
$image = $decoder->decode(file_get_contents($this->getTestImagePath('tile.png')));
$this->assertInstanceOf(Image::class, $image);
$this->assertEquals(16, $image->getWidth());
$this->assertEquals(16, $image->getHeight());
Expand All @@ -21,7 +21,7 @@ public function testDecodePng(): void
public function testDecodeGif(): void
{
$decoder = new BinaryImageDecoder();
$image = $decoder->decode(file_get_contents(__DIR__ . '/../../../images/red.gif'));
$image = $decoder->decode(file_get_contents($this->getTestImagePath('red.gif')));
$this->assertInstanceOf(Image::class, $image);
$this->assertEquals(16, $image->getWidth());
$this->assertEquals(16, $image->getHeight());
Expand All @@ -31,10 +31,21 @@ public function testDecodeGif(): void
public function testDecodeAnimatedGif(): void
{
$decoder = new BinaryImageDecoder();
$image = $decoder->decode(file_get_contents(__DIR__ . '/../../../images/cats.gif'));
$image = $decoder->decode(file_get_contents($this->getTestImagePath('cats.gif')));
$this->assertInstanceOf(Image::class, $image);
$this->assertEquals(75, $image->getWidth());
$this->assertEquals(50, $image->getHeight());
$this->assertCount(4, $image);
}

public function testDecodeJpegWithExif(): void
{
$decoder = new BinaryImageDecoder();
$image = $decoder->decode(file_get_contents($this->getTestImagePath('exif.jpg')));
$this->assertInstanceOf(Image::class, $image);
$this->assertEquals(16, $image->getWidth());
$this->assertEquals(16, $image->getHeight());
$this->assertCount(1, $image);
$this->assertEquals('Oliver Vogel', $image->getExif('IFD0.Artist'));
}
}
Binary file added tests/images/exif.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f15a309

Please sign in to comment.