Skip to content

Commit

Permalink
Add avif support
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Oct 3, 2023
1 parent d79dd50 commit 3265635
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ $type = $sniffer->setFromFilename('images/image.jpg')->getType();
- Scalable Vector Graphics (SVG)
- Tagged Image File Format (TIFF)
- Image encoded Photoshop Document file format (PSD)
- AV1 Image File Format (AVIF)

### Archives

Expand Down
22 changes: 22 additions & 0 deletions src/Types/ImageAvif.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Intervention\MimeSniffer\Types;

use Intervention\MimeSniffer\AbstractBinaryType;

class ImageAvif extends AbstractBinaryType
{
/**
* Name of content type
*
* @var string
*/
public $name = "image/avif";

/**
* Signature pattern
*
* @var string
*/
protected $pattern = "/^0000001C66747970/";
}
29 changes: 29 additions & 0 deletions tests/ImageAvifTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Intervention\MimeSniffer\Test;

use PHPUnit\Framework\TestCase;
use Intervention\MimeSniffer\MimeSniffer;
use Intervention\MimeSniffer\Types\ImageAvif;

class ImageAvifTest extends TestCase
{
public $sniffer;
public $type;

protected function setUp(): void
{
$this->sniffer = MimeSniffer::createFromFilename(__DIR__ . '/../tests/stubs/avif');
$this->type = $this->sniffer->getType();
}

public function testType()
{
$this->assertInstanceOf(ImageAvif::class, $this->type);
}

public function testIsImage()
{
$this->assertTrue($this->type->isImage());
}
}
Binary file added tests/stubs/avif
Binary file not shown.

0 comments on commit 3265635

Please sign in to comment.