Skip to content

Commit

Permalink
PHP 7.2 Support
Browse files Browse the repository at this point in the history
  • Loading branch information
darrynten committed Aug 17, 2018
1 parent ed1b391 commit af77018
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: php
php:
- 7.1
- 7.2
before_script:
- sudo apt-get install libjpeg-dev libpng-dev libtiff-dev libgif-dev webp openjpeg-tools
- wget https://github.com/ImageMagick/ImageMagick/archive/7.0.7-21.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/BaseLayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public function getLayerDetailsJson()

public function render()
{
if (sizeof($this->filters->collection > 0)) {
if (sizeof($this->filters->collection)) {
foreach ($this->filters->collection as $filter) {
$filter->setImage($this->canvas);
$filter->render();
Expand Down
29 changes: 29 additions & 0 deletions src/Layers/Layer/TextLayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ class TextLayer extends BaseLayer
*/
public $strokeOpacity;

/**
* Rotation
*
* @var float $rotation The angle of the text.
*/
public $rotation;

/**
* Construct the text layer
*/
Expand Down Expand Up @@ -187,6 +194,10 @@ public function __construct(array $config)
!empty($config['strokeOpacity']) ? $config['strokeOpacity'] : 0.0
);

$this->rotation(
!empty($config['rotation']) ? $config['rotation'] : 0.0
);

parent::__construct($config);
}

Expand Down Expand Up @@ -430,6 +441,22 @@ public function textDecoration(int $textDecoration = null)
return $this->textDecoration = $textDecoration;
}

/**
* Get and set the rotation
*
* @param null|float $rotation The rotation in degrees
*
* @return boolean|float
*/
public function rotation(float $rotation = null)
{
if ($rotation === null) {
return $this->rotation;
}

return $this->rotation = $rotation;
}

/**
* Get and set the text
*
Expand Down Expand Up @@ -479,6 +506,8 @@ public function render()
$this->positionY = $this->positionY + $dimensions['textHeight'] * 0.66;

$this->canvas->annotateImage($draw, $this->positionX, $this->positionY, 0, $this->text);
$this->canvas->rotateImage(new \ImagickPixel('#00000000'), $this->rotation);
$this->canvas->setImagePage($this->canvas->getImageWidth(), $this->canvas->getImageHeight(), 0, 0);

return $this->canvas;
}
Expand Down

0 comments on commit af77018

Please sign in to comment.