frimagick: add flipfloprotate
Signed-off-by: Varun Patil <varunpatil@ucla.edu>pull/579/head
parent
e23afa41cc
commit
ec1ad319b6
25
test.php
25
test.php
|
@ -27,6 +27,12 @@ class ImageState {
|
||||||
public ?float $cropWidth = null;
|
public ?float $cropWidth = null;
|
||||||
/** Crop height */
|
/** Crop height */
|
||||||
public ?float $cropHeight = null;
|
public ?float $cropHeight = null;
|
||||||
|
/** Rotation */
|
||||||
|
public ?int $rotation = null;
|
||||||
|
/** Flipped X */
|
||||||
|
public bool $isFlippedX = false;
|
||||||
|
/** Flipped Y */
|
||||||
|
public bool $isFlippedY = false;
|
||||||
|
|
||||||
public function __construct(array $json)
|
public function __construct(array $json)
|
||||||
{
|
{
|
||||||
|
@ -61,6 +67,9 @@ class ImageState {
|
||||||
$this->_set($crop, 'width', 'cropWidth');
|
$this->_set($crop, 'width', 'cropWidth');
|
||||||
$this->_set($crop, 'height', 'cropHeight');
|
$this->_set($crop, 'height', 'cropHeight');
|
||||||
}
|
}
|
||||||
|
$this->_set($props, 'rotation');
|
||||||
|
$this->_set($props, 'isFlippedX');
|
||||||
|
$this->_set($props, 'isFlippedY');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +93,7 @@ class KonvaMagick {
|
||||||
|
|
||||||
public function apply() {
|
public function apply() {
|
||||||
$this->applyCrop();
|
$this->applyCrop();
|
||||||
|
$this->applyFlipRotation();
|
||||||
|
|
||||||
foreach ($this->state->finetuneOrder as $key) {
|
foreach ($this->state->finetuneOrder as $key) {
|
||||||
$method = 'apply' . $key;
|
$method = 'apply' . $key;
|
||||||
|
@ -106,6 +116,18 @@ class KonvaMagick {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function applyFlipRotation() {
|
||||||
|
if ($this->state->isFlippedX) {
|
||||||
|
$this->image->flopImage();
|
||||||
|
}
|
||||||
|
if ($this->state->isFlippedY) {
|
||||||
|
$this->image->flipImage();
|
||||||
|
}
|
||||||
|
if ($this->state->rotation) {
|
||||||
|
$this->image->rotateImage(new \ImagickPixel(), $this->state->rotation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function applyBrighten() {
|
protected function applyBrighten() {
|
||||||
$brightness = $this->state->brightness ?? 0;
|
$brightness = $this->state->brightness ?? 0;
|
||||||
if ($brightness === 0) {
|
if ($brightness === 0) {
|
||||||
|
@ -208,6 +230,9 @@ $imageState = new ImageState([
|
||||||
'width' => 0.47661152675402463,
|
'width' => 0.47661152675402463,
|
||||||
'height' => 0.47661153565936554,
|
'height' => 0.47661153565936554,
|
||||||
],
|
],
|
||||||
|
'rotation' => 90,
|
||||||
|
'isFlippedX' => false,
|
||||||
|
'isFlippedY' => true,
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue