Skip to content

Commit 6e04aa9

Browse files
authored
Merge pull request #19 from JeffAlyanak/new-commands-transpose-and-transerse
New commands transpose and transverse
2 parents 7f7a0d7 + 838dce9 commit 6e04aa9

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

Command.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,26 @@ public function colorspace(string $colorspace): self
618618
return $this;
619619
}
620620

621+
/**
622+
* @see http://imagemagick.org/script/command-line-options.php#transpose
623+
*/
624+
public function transpose(): self
625+
{
626+
$this->command[] = '-transpose';
627+
628+
return $this;
629+
}
630+
631+
/**
632+
* @see http://imagemagick.org/script/command-line-options.php#transverse
633+
*/
634+
public function transverse(): self
635+
{
636+
$this->command[] = '-transverse';
637+
638+
return $this;
639+
}
640+
621641
/**
622642
* /!\ Append a raw command to ImageMagick.
623643
* Not safe! Use at your own risks!

Tests/CommandTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,44 @@ public function testFlattenImage(): void
116116
$this->testConvertIdentifyImage($imageOutput, 'JPEG', '180x170+0+0', '8-bit');
117117
}
118118

119+
public function testTranspose(): void
120+
{
121+
$command = new Command(IMAGEMAGICK_DIR);
122+
123+
$imageSource = $this->resourcesDir.'/moon_180.jpg';
124+
$imageOutput = $this->resourcesDir.'/outputs/moon_transpose.jpg';
125+
static::assertFileExists($imageSource);
126+
127+
$response = $command
128+
->convert($imageSource)
129+
->transpose()
130+
->file($imageOutput, false)
131+
->run()
132+
;
133+
134+
static::assertFalse($response->hasFailed());
135+
static::assertFileExists($this->resourcesDir.'/outputs/moon_transpose.jpg');
136+
}
137+
138+
public function testTransverse(): void
139+
{
140+
$command = new Command(IMAGEMAGICK_DIR);
141+
142+
$imageSource = $this->resourcesDir.'/moon_180.jpg';
143+
$imageOutput = $this->resourcesDir.'/outputs/moon_transverse.jpg';
144+
static::assertFileExists($imageSource);
145+
146+
$response = $command
147+
->convert($imageSource)
148+
->transverse()
149+
->file($imageOutput, false)
150+
->run()
151+
;
152+
153+
static::assertFalse($response->hasFailed());
154+
static::assertFileExists($this->resourcesDir.'/outputs/moon_transverse.jpg');
155+
}
156+
119157
public function testColorspaceImage(): void
120158
{
121159
$command = new Command(IMAGEMAGICK_DIR);

0 commit comments

Comments
 (0)