diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 39a6579a..6d841830 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -14,7 +14,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: php-version: '7.4' - extensions: gd + extensions: gd, imagick - name: php-cs-fixer run: | wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.16.4/php-cs-fixer.phar -q @@ -36,7 +36,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} - extensions: gd + extensions: gd, imagick coverage: pcov - name: Composer @@ -66,7 +66,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: php-version: '7.4' - extensions: gd + extensions: gd, imagick tools: vimeo/psalm:4.15 - name: psalm run: | diff --git a/src/Manipulators/Encode.php b/src/Manipulators/Encode.php index 87294731..8b78fb57 100644 --- a/src/Manipulators/Encode.php +++ b/src/Manipulators/Encode.php @@ -52,6 +52,7 @@ public function getFormat(Image $image) 'pjpg' => 'image/jpeg', 'png' => 'image/png', 'webp' => 'image/webp', + 'tiff' => 'image/tiff', ]; if (array_key_exists($this->fm, $allowed)) { diff --git a/tests/Manipulators/EncodeTest.php b/tests/Manipulators/EncodeTest.php index 171d5892..8cb3b8c2 100644 --- a/tests/Manipulators/EncodeTest.php +++ b/tests/Manipulators/EncodeTest.php @@ -132,4 +132,28 @@ public function testGetQuality() $this->assertSame(90, $this->manipulator->setParams(['q' => '-1'])->getQuality()); $this->assertSame(90, $this->manipulator->setParams(['q' => '101'])->getQuality()); } + + /** + * Test functions that require the imagick extension. + * + * @return void + */ + public function testWithImagick() + { + if (!extension_loaded('imagick')) { + $this->markTestSkipped( + 'The imagick extension is not available.' + ); + } + $manager = new ImageManager(['driver' => 'imagick']); + //These need to be recreated with the imagick driver selected in the manager + $this->jpg = $manager->canvas(100, 100)->encode('jpg'); + $this->png = $manager->canvas(100, 100)->encode('png'); + $this->gif = $manager->canvas(100, 100)->encode('gif'); + $this->tif = $manager->canvas(100, 100)->encode('tiff'); + + $this->assertSame('image/tiff', $this->manipulator->setParams(['fm' => 'tiff'])->run($this->jpg)->mime); + $this->assertSame('image/tiff', $this->manipulator->setParams(['fm' => 'tiff'])->run($this->png)->mime); + $this->assertSame('image/tiff', $this->manipulator->setParams(['fm' => 'tiff'])->run($this->gif)->mime); + } }