mirror of
https://github.com/Intervention/image.git
synced 2025-01-17 20:28:21 +01:00
Add tests for EXIF data reading
This commit is contained in:
parent
d317c47871
commit
f15a30932c
@ -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());
|
||||
@ -25,7 +25,7 @@ class BinaryImageDecoderTest extends TestCase
|
||||
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());
|
||||
@ -35,10 +35,21 @@ class BinaryImageDecoderTest extends TestCase
|
||||
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'));
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
@ -21,7 +21,7 @@ class BinaryImageDecoderTest extends TestCase
|
||||
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());
|
||||
@ -31,10 +31,21 @@ class BinaryImageDecoderTest extends TestCase
|
||||
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'));
|
||||
}
|
||||
}
|
||||
|
BIN
tests/images/exif.jpg
Normal file
BIN
tests/images/exif.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.6 KiB |
Loading…
x
Reference in New Issue
Block a user