Skip to content

Commit

Permalink
Enable TIFF image format handling, fixes thephpleague#344
Browse files Browse the repository at this point in the history
  • Loading branch information
Synchro committed Feb 20, 2022
1 parent 3aa4539 commit 0499ee8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
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 0499ee8

Please sign in to comment.