diff --git a/Command.php b/Command.php index 890ae23..9ddb1a1 100644 --- a/Command.php +++ b/Command.php @@ -618,6 +618,26 @@ public function colorspace(string $colorspace): self return $this; } + /** + * @see http://imagemagick.org/script/command-line-options.php#transpose + */ + public function transpose(): self + { + $this->command[] = '-transpose'; + + return $this; + } + + /** + * @see http://imagemagick.org/script/command-line-options.php#transverse + */ + public function transverse(): self + { + $this->command[] = '-transverse'; + + return $this; + } + /** * /!\ Append a raw command to ImageMagick. * Not safe! Use at your own risks! diff --git a/Tests/CommandTest.php b/Tests/CommandTest.php index 4710bd6..4300dd3 100644 --- a/Tests/CommandTest.php +++ b/Tests/CommandTest.php @@ -116,6 +116,44 @@ public function testFlattenImage(): void $this->testConvertIdentifyImage($imageOutput, 'JPEG', '180x170+0+0', '8-bit'); } + public function testTranspose(): void + { + $command = new Command(IMAGEMAGICK_DIR); + + $imageSource = $this->resourcesDir.'/moon_180.jpg'; + $imageOutput = $this->resourcesDir.'/outputs/moon_transpose.jpg'; + static::assertFileExists($imageSource); + + $response = $command + ->convert($imageSource) + ->transpose() + ->file($imageOutput, false) + ->run() + ; + + static::assertFalse($response->hasFailed()); + static::assertFileExists($this->resourcesDir.'/outputs/moon_transpose.jpg'); + } + + public function testTransverse(): void + { + $command = new Command(IMAGEMAGICK_DIR); + + $imageSource = $this->resourcesDir.'/moon_180.jpg'; + $imageOutput = $this->resourcesDir.'/outputs/moon_transverse.jpg'; + static::assertFileExists($imageSource); + + $response = $command + ->convert($imageSource) + ->transverse() + ->file($imageOutput, false) + ->run() + ; + + static::assertFalse($response->hasFailed()); + static::assertFileExists($this->resourcesDir.'/outputs/moon_transverse.jpg'); + } + public function testColorspaceImage(): void { $command = new Command(IMAGEMAGICK_DIR);