Skip to content

Commit

Permalink
Merge pull request #3 from mizmiz/master
Browse files Browse the repository at this point in the history
Fixes colors and image size
  • Loading branch information
mizmiz authored Jan 10, 2022
2 parents e7b9c43 + 8f8f8c4 commit 90772e3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
.DS_Store
28 changes: 11 additions & 17 deletions lib/effect_insert_text.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,22 @@ public function execute()
$position[1] = (string) $txtparams[4];
}

// Default Padding
$padding = [0, 30];
// Default Margin
$margin = [0, 30];

// Padding
if (isset($this->params['padding_x']) && $this->params['padding_x'] <> '') {
$padding[0] = (int) $this->params['padding_x'];
$margin[0] = (int) $this->params['padding_x'];
}
if (isset($txtparams[5]) && $txtparams[5] <> '') {
$padding[0] = (int) $txtparams[5];
$margin[0] = (int) $txtparams[5];
}

if (isset($this->params['padding_y']) && $this->params['padding_y'] <> '') {
$padding[1] = (int) $this->params['padding_y'];
$margin[1] = (int) $this->params['padding_y'];
}
if (isset($txtparams[6]) && $txtparams[6] <> '') {
$padding[1] = (int) $txtparams[6];
$margin[1] = (int) $txtparams[6];
}

// Antialiasing
Expand Down Expand Up @@ -247,9 +247,6 @@ public function execute()
// Write text shadow
if ($outputshadow) {
$col = imagecolorallocatealpha($gdTemp, $shadowcolor[0], $shadowcolor[1], $shadowcolor[2], $shadowalpha);
if ($antialiasing === 0) {
$col = -$col;
}
imagettftext(
$gdTemp,
$fontSize * $scale,
Expand All @@ -264,9 +261,6 @@ public function execute()

// Write text
$col = imagecolorallocatealpha($gdTemp, $color[0], $color[1], $color[2], $alpha);
if ($antialiasing === 0) {
$col = -$col;
}
imagettftext(
$gdTemp,
$fontSize * $scale,
Expand All @@ -285,8 +279,8 @@ public function execute()
// get new Image-Size
$imgWidth = imagesx($gdTemp);
$imgHeight = imagesy($gdTemp);
$the_box['width'] = $imgWidth;
$the_box['height'] = $imgHeight;
$the_box['width'] = $imgWidth / $scale;
$the_box['height'] = $imgHeight / $scale;
$bgpadding = 0;
}

Expand Down Expand Up @@ -324,8 +318,8 @@ public function execute()
imagecopyresampled(
$sourceImage,
$gdTemp,
$dstX + $padding[0],
$dstY + $padding[1],
$dstX + $margin[0],
$dstY + $margin[1],
0,
0,
$the_box['width'] + ($bgpadding*2),
Expand Down Expand Up @@ -509,7 +503,7 @@ public function getParams()
'type' => 'select',
'options' => ['left', 'center', 'right'],
'default' => 'center',
],
],
[
'label' => rex_i18n::msg('media_manager_effect_insert_text_vpos'),
'name' => 'vpos',
Expand Down
2 changes: 1 addition & 1 deletion package.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package: insert_text
version: "2.0.0"
version: "2.0.1"
name: Insert Text
author: Friends Of REDAXO
supportpage: https://github.com/FriendsOfREDAXO/insert_text
Expand Down

0 comments on commit 90772e3

Please sign in to comment.