mirror of
https://github.com/Intervention/image.git
synced 2025-08-06 13:56:30 +02:00
Add tests for EXIF data reading
This commit is contained in:
@@ -15,7 +15,7 @@ class BinaryImageDecoderTest extends TestCase
|
|||||||
public function testDecodePng(): void
|
public function testDecodePng(): void
|
||||||
{
|
{
|
||||||
$decoder = new BinaryImageDecoder();
|
$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->assertInstanceOf(Image::class, $image);
|
||||||
$this->assertEquals(16, $image->getWidth());
|
$this->assertEquals(16, $image->getWidth());
|
||||||
$this->assertEquals(16, $image->getHeight());
|
$this->assertEquals(16, $image->getHeight());
|
||||||
@@ -25,7 +25,7 @@ class BinaryImageDecoderTest extends TestCase
|
|||||||
public function testDecodeGif(): void
|
public function testDecodeGif(): void
|
||||||
{
|
{
|
||||||
$decoder = new BinaryImageDecoder();
|
$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->assertInstanceOf(Image::class, $image);
|
||||||
$this->assertEquals(16, $image->getWidth());
|
$this->assertEquals(16, $image->getWidth());
|
||||||
$this->assertEquals(16, $image->getHeight());
|
$this->assertEquals(16, $image->getHeight());
|
||||||
@@ -35,10 +35,21 @@ class BinaryImageDecoderTest extends TestCase
|
|||||||
public function testDecodeAnimatedGif(): void
|
public function testDecodeAnimatedGif(): void
|
||||||
{
|
{
|
||||||
$decoder = new BinaryImageDecoder();
|
$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->assertInstanceOf(Image::class, $image);
|
||||||
$this->assertEquals(75, $image->getWidth());
|
$this->assertEquals(75, $image->getWidth());
|
||||||
$this->assertEquals(50, $image->getHeight());
|
$this->assertEquals(50, $image->getHeight());
|
||||||
$this->assertCount(4, $image);
|
$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
|
public function testDecodePng(): void
|
||||||
{
|
{
|
||||||
$decoder = new BinaryImageDecoder();
|
$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->assertInstanceOf(Image::class, $image);
|
||||||
$this->assertEquals(16, $image->getWidth());
|
$this->assertEquals(16, $image->getWidth());
|
||||||
$this->assertEquals(16, $image->getHeight());
|
$this->assertEquals(16, $image->getHeight());
|
||||||
@@ -21,7 +21,7 @@ class BinaryImageDecoderTest extends TestCase
|
|||||||
public function testDecodeGif(): void
|
public function testDecodeGif(): void
|
||||||
{
|
{
|
||||||
$decoder = new BinaryImageDecoder();
|
$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->assertInstanceOf(Image::class, $image);
|
||||||
$this->assertEquals(16, $image->getWidth());
|
$this->assertEquals(16, $image->getWidth());
|
||||||
$this->assertEquals(16, $image->getHeight());
|
$this->assertEquals(16, $image->getHeight());
|
||||||
@@ -31,10 +31,21 @@ class BinaryImageDecoderTest extends TestCase
|
|||||||
public function testDecodeAnimatedGif(): void
|
public function testDecodeAnimatedGif(): void
|
||||||
{
|
{
|
||||||
$decoder = new BinaryImageDecoder();
|
$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->assertInstanceOf(Image::class, $image);
|
||||||
$this->assertEquals(75, $image->getWidth());
|
$this->assertEquals(75, $image->getWidth());
|
||||||
$this->assertEquals(50, $image->getHeight());
|
$this->assertEquals(50, $image->getHeight());
|
||||||
$this->assertCount(4, $image);
|
$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 |
Reference in New Issue
Block a user