@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param RGBAColor|null $trimColor |
38 | 38 | * @throws ImageHelper_Exception |
39 | 39 | */ |
40 | - public function __construct(ImageHelper $helper, $sourceImage, ?RGBAColor $trimColor=null) |
|
40 | + public function __construct(ImageHelper $helper, $sourceImage, ?RGBAColor $trimColor = null) |
|
41 | 41 | { |
42 | 42 | ImageHelper::requireResource($sourceImage); |
43 | 43 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | { |
51 | 51 | $targetColor = ColorFactory::createAuto($trimColor); |
52 | 52 | |
53 | - if($targetColor !== null) |
|
53 | + if ($targetColor !== null) |
|
54 | 54 | { |
55 | 55 | return $targetColor; |
56 | 56 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | ) |
80 | 80 | ); |
81 | 81 | |
82 | - if($img !== false) { |
|
82 | + if ($img !== false) { |
|
83 | 83 | return $img; |
84 | 84 | } |
85 | 85 | |
@@ -99,16 +99,16 @@ discard block |
||
99 | 99 | $ymax = null; |
100 | 100 | |
101 | 101 | // Start scanning for the edges. |
102 | - for ($iy=0; $iy<$imh; $iy++) |
|
102 | + for ($iy = 0; $iy < $imh; $iy++) |
|
103 | 103 | { |
104 | 104 | $first = true; |
105 | 105 | |
106 | - for ($ix=0; $ix<$imw; $ix++) |
|
106 | + for ($ix = 0; $ix < $imw; $ix++) |
|
107 | 107 | { |
108 | 108 | $ndx = imagecolorat($this->sourceImage, $ix, $iy); |
109 | 109 | $colors = $this->helper->getIndexedColors($this->sourceImage, $ndx); |
110 | 110 | |
111 | - if(!$colors->matchesAlpha($this->trimColor)) |
|
111 | + if (!$colors->matchesAlpha($this->trimColor)) |
|
112 | 112 | { |
113 | 113 | if ($xmin > $ix) { $xmin = $ix; } |
114 | 114 | if ($xmax < $ix) { $xmax = $ix; } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | $ymax = $iy; |
118 | 118 | |
119 | - if($first) |
|
119 | + if ($first) |
|
120 | 120 | { |
121 | 121 | $ix = $xmax; |
122 | 122 | $first = false; |
@@ -126,18 +126,18 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | // no trimming border found |
129 | - if($ymax === null) { |
|
129 | + if ($ymax === null) { |
|
130 | 130 | return $this->sourceImage; |
131 | 131 | } |
132 | 132 | |
133 | 133 | // The new width and height of the image. |
134 | - $imw = 1+$xmax-$xmin; // Image width in pixels |
|
135 | - $imh = 1+$ymax-$ymin; // Image height in pixels |
|
134 | + $imw = 1 + $xmax - $xmin; // Image width in pixels |
|
135 | + $imh = 1 + $ymax - $ymin; // Image height in pixels |
|
136 | 136 | |
137 | 137 | // Make another image to place the trimmed version in. |
138 | 138 | $im2 = $this->helper->createNewImage($imw, $imh); |
139 | 139 | |
140 | - if($this->trimColor->hasTransparency()) |
|
140 | + if ($this->trimColor->hasTransparency()) |
|
141 | 141 | { |
142 | 142 | $bg2 = imagecolorallocatealpha( |
143 | 143 | $im2, |
@@ -148,8 +148,7 @@ |
||
148 | 148 | ); |
149 | 149 | |
150 | 150 | imagecolortransparent($im2, $bg2); |
151 | - } |
|
152 | - else |
|
151 | + } else |
|
153 | 152 | { |
154 | 153 | $bg2 = imagecolorallocate( |
155 | 154 | $im2, |