Skip to content

Commit

Permalink
Add Jpeg2000 format
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Oct 7, 2024
1 parent 017f3da commit e2c1ed1
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ $type = $sniffer->setFromPointer(fopen('images/image.jpg', 'r'))->getType();
- Tagged Image File Format (TIFF)
- Image encoded Photoshop Document file format (PSD)
- AV1 Image File Format (AVIF)
- JPEG 2000 File Format

### Archives

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

declare(strict_types=1);

namespace Intervention\MimeSniffer\Types;

use Intervention\MimeSniffer\AbstractBinaryType;

class ImageJpeg2000 extends AbstractBinaryType
{
/**
* Name of content type
*
* @var string
*/
public $name = 'image/jp2';

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

declare(strict_types=1);

namespace Intervention\MimeSniffer\Tests;

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

final class ImageJpeg2000Test extends TestCase
{
public $sniffer;
public $type;

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

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

public function testIsImage(): void
{
$this->assertTrue($this->type->isImage());
}
}
Binary file added tests/files/test.jp2
Binary file not shown.

0 comments on commit e2c1ed1

Please sign in to comment.