Skip to content

Commit f178449

Browse files
committed
Added monochrome Command
monochrome: transform image to black and white (http://imagemagick.org/script/command-line-options.php#monochrome)
1 parent defabc8 commit f178449

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
@@ -475,6 +475,17 @@ public function strip(): self
475475
return $this;
476476
}
477477

478+
479+
/**
480+
* @see http://imagemagick.org/script/command-line-options.php#monochrome
481+
*/
482+
public function monochrome(): self
483+
{
484+
$this->command[] = '-monochrome';
485+
486+
return $this;
487+
}
488+
478489
/**
479490
* @see http://imagemagick.org/script/command-line-options.php#interlace
480491
*/

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
/**
144163
* @dataProvider provideImagesToIdentify
145164
*/

0 commit comments

Comments
 (0)