Skip to content

Commit 082ad12

Browse files
committed
fixing qrcode merge error
1 parent 7e4ce1a commit 082ad12

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/Image.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,14 @@ public function getImageResource()
5050
{
5151
return $this->image;
5252
}
53+
54+
/**
55+
* Sets the image string.
56+
*
57+
* @param resource $image
58+
*/
59+
public function setImageResource($image)
60+
{
61+
$this->image = $image;
62+
}
5363
}

src/ImageMerge.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,24 @@ public function merge($percentage)
107107
{
108108
$this->setProperties($percentage);
109109

110-
imagecopyresampled(
110+
$img = imagecreatetruecolor($this->sourceImage->getWidth(), $this->sourceImage->getHeight());
111+
imagealphablending($img, true);
112+
$transparent = imagecolorallocatealpha($img, 0, 0, 0, 127);
113+
imagefill($img, 0, 0, $transparent);
114+
115+
imagecopy(
116+
$img,
111117
$this->sourceImage->getImageResource(),
118+
0,
119+
0,
120+
0,
121+
0,
122+
$this->sourceImage->getWidth(),
123+
$this->sourceImage->getHeight()
124+
);
125+
126+
imagecopyresampled(
127+
$img,
112128
$this->mergeImage->getImageResource(),
113129
$this->centerX,
114130
$this->centerY,
@@ -120,6 +136,8 @@ public function merge($percentage)
120136
$this->mergeImageHeight
121137
);
122138

139+
$this->sourceImage->setImageResource($img);
140+
123141
return $this->createImage();
124142
}
125143

0 commit comments

Comments
 (0)