Skip to content

Commit 77571fb

Browse files
committed
Updated GD.php, hotfix for pad() transparency (masterexploder#111)
1 parent 69fe4db commit 77571fb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/PHPThumb/GD.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function __destruct()
130130
* @param array $color
131131
* @return GD
132132
*/
133-
public function pad($width, $height, $color = array(255, 255, 255))
133+
public function pad($width, $height, $color = array(255, 255, 255, 127))
134134
{
135135
// no resize - woohoo!
136136
if ($width == $this->currentDimensions['width'] && $height == $this->currentDimensions['height']) {
@@ -144,12 +144,16 @@ public function pad($width, $height, $color = array(255, 255, 255))
144144
$this->workingImage = imagecreate($width, $height);
145145
}
146146

147+
imagealphablending($this->workingImage, false);
148+
imagesavealpha($this->workingImage, true);
149+
147150
// create the fill color
148-
$fillColor = imagecolorallocate(
151+
$fillColor = imagecolorallocatealpha(
149152
$this->workingImage,
150153
$color[0],
151154
$color[1],
152-
$color[2]
155+
$color[2],
156+
$color[3]
153157
);
154158

155159
// fill our working image with the fill color

0 commit comments

Comments
 (0)