Skip to content

Commit

Permalink
Enable TIFF image format handling, fixes #344 (#345)
Browse files Browse the repository at this point in the history
Enable TIFF image format handling, fixes #344
  • Loading branch information
Synchro authored Feb 21, 2022
1 parent 3aa4539 commit bff5b0f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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: |
Expand Down
1 change: 1 addition & 0 deletions src/Manipulators/Encode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
24 changes: 24 additions & 0 deletions tests/Manipulators/EncodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit bff5b0f

Please sign in to comment.