Skip to content

Commit

Permalink
Merge pull request #19 from JeffAlyanak/new-commands-transpose-and-tr…
Browse files Browse the repository at this point in the history
…anserse

New commands transpose and transverse
  • Loading branch information
Pierstoval authored Jan 1, 2020
2 parents 7f7a0d7 + 838dce9 commit 6e04aa9
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
38 changes: 38 additions & 0 deletions Tests/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6e04aa9

Please sign in to comment.