Skip to content

Commit 7f7a0d7

Browse files
authored
Merge pull request #20 from JeffAlyanak/new-command-monochrome
Added monochrome Command
2 parents f97555b + d85482d commit 7f7a0d7

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

Command.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,17 @@ public function strip(): self
489489
return $this;
490490
}
491491

492+
493+
/**
494+
* @see http://imagemagick.org/script/command-line-options.php#monochrome
495+
*/
496+
public function monochrome(): self
497+
{
498+
$this->command[] = '-monochrome';
499+
500+
return $this;
501+
}
502+
492503
/**
493504
* @see http://imagemagick.org/script/command-line-options.php#interlace
494505
*/

Tests/CommandTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,25 @@ public function testColorspaceImage(): void
140140
$this->testConvertIdentifyImage($imageOutput, 'JPEG', '180x170+0+0', '8-bit');
141141
}
142142

143+
public function testMonochrome(): void
144+
{
145+
$command = new Command(IMAGEMAGICK_DIR);
146+
147+
$imageSource = $this->resourcesDir.'/moon_180.jpg';
148+
$imageOutput = $this->resourcesDir.'/outputs/moon_monochrome.jpg';
149+
static::assertFileExists($imageSource);
150+
151+
$response = $command
152+
->convert($imageSource)
153+
->monochrome()
154+
->file($imageOutput, false)
155+
->run()
156+
;
157+
158+
static::assertFalse($response->hasFailed());
159+
static::assertFileExists($this->resourcesDir.'/outputs/moon_monochrome.jpg');
160+
}
161+
143162
public function testGravityCommand(): void
144163
{
145164
$command = new Command(IMAGEMAGICK_DIR);

0 commit comments

Comments
 (0)