Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions system/Images/Handlers/ImageMagickHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,10 @@ protected function _flip(string $direction)
*/
public function getVersion(): string
{
$result = $this->process('-version');
$versionString = $this->process('-version')[0];
preg_match('/ImageMagick\s(?P<version>[\S]+)/', $versionString, $matches);

// The first line has the version in it...
preg_match('/(ImageMagick\s[\S]+)/', $result[0], $matches);

return str_replace('ImageMagick ', '', $matches[0]);
return $matches['version'];
}

/**
Expand Down
9 changes: 4 additions & 5 deletions tests/system/Images/ImageMagickHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@ protected function setUp(): void
public function testGetVersion(): void
{
$version = $this->handler->getVersion();
// make sure that the call worked
$this->assertNotFalse($version);
// we should have a numeric version, greater than 6
$this->assertGreaterThanOrEqual(0, version_compare($version, '6.0.0'));
$this->assertLessThan(0, version_compare($version, '99.0.0'));

$this->assertNotSame('', $version);
$this->assertTrue(version_compare($version, '6.0.0', '>'));
$this->assertTrue(version_compare($version, '99.0.0', '<'));
}

public function testImageProperties(): void
Expand Down