Skip to content

Commit bff5b0f

Browse files
authored
Enable TIFF image format handling, fixes #344 (#345)
Enable TIFF image format handling, fixes #344
1 parent 3aa4539 commit bff5b0f

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

.github/workflows/test.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: shivammathur/setup-php@v2
1515
with:
1616
php-version: '7.4'
17-
extensions: gd
17+
extensions: gd, imagick
1818
- name: php-cs-fixer
1919
run: |
2020
wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.16.4/php-cs-fixer.phar -q
@@ -36,7 +36,7 @@ jobs:
3636
- uses: shivammathur/setup-php@v2
3737
with:
3838
php-version: ${{ matrix.php-version }}
39-
extensions: gd
39+
extensions: gd, imagick
4040
coverage: pcov
4141

4242
- name: Composer
@@ -66,7 +66,7 @@ jobs:
6666
- uses: shivammathur/setup-php@v2
6767
with:
6868
php-version: '7.4'
69-
extensions: gd
69+
extensions: gd, imagick
7070
tools: vimeo/psalm:4.15
7171
- name: psalm
7272
run: |

src/Manipulators/Encode.php

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public function getFormat(Image $image)
5252
'pjpg' => 'image/jpeg',
5353
'png' => 'image/png',
5454
'webp' => 'image/webp',
55+
'tiff' => 'image/tiff',
5556
];
5657

5758
if (array_key_exists($this->fm, $allowed)) {

tests/Manipulators/EncodeTest.php

+24
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,28 @@ public function testGetQuality()
132132
$this->assertSame(90, $this->manipulator->setParams(['q' => '-1'])->getQuality());
133133
$this->assertSame(90, $this->manipulator->setParams(['q' => '101'])->getQuality());
134134
}
135+
136+
/**
137+
* Test functions that require the imagick extension.
138+
*
139+
* @return void
140+
*/
141+
public function testWithImagick()
142+
{
143+
if (!extension_loaded('imagick')) {
144+
$this->markTestSkipped(
145+
'The imagick extension is not available.'
146+
);
147+
}
148+
$manager = new ImageManager(['driver' => 'imagick']);
149+
//These need to be recreated with the imagick driver selected in the manager
150+
$this->jpg = $manager->canvas(100, 100)->encode('jpg');
151+
$this->png = $manager->canvas(100, 100)->encode('png');
152+
$this->gif = $manager->canvas(100, 100)->encode('gif');
153+
$this->tif = $manager->canvas(100, 100)->encode('tiff');
154+
155+
$this->assertSame('image/tiff', $this->manipulator->setParams(['fm' => 'tiff'])->run($this->jpg)->mime);
156+
$this->assertSame('image/tiff', $this->manipulator->setParams(['fm' => 'tiff'])->run($this->png)->mime);
157+
$this->assertSame('image/tiff', $this->manipulator->setParams(['fm' => 'tiff'])->run($this->gif)->mime);
158+
}
135159
}

0 commit comments

Comments
 (0)