Skip to content

Commit

Permalink
fixing qrcode merge error
Browse files Browse the repository at this point in the history
  • Loading branch information
lyekumchew committed Oct 7, 2020
1 parent 7e4ce1a commit 082ad12
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,14 @@ public function getImageResource()
{
return $this->image;
}

/**
* Sets the image string.
*
* @param resource $image
*/
public function setImageResource($image)
{
$this->image = $image;
}
}
20 changes: 19 additions & 1 deletion src/ImageMerge.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,24 @@ public function merge($percentage)
{
$this->setProperties($percentage);

imagecopyresampled(
$img = imagecreatetruecolor($this->sourceImage->getWidth(), $this->sourceImage->getHeight());
imagealphablending($img, true);
$transparent = imagecolorallocatealpha($img, 0, 0, 0, 127);
imagefill($img, 0, 0, $transparent);

imagecopy(
$img,
$this->sourceImage->getImageResource(),
0,
0,
0,
0,
$this->sourceImage->getWidth(),
$this->sourceImage->getHeight()
);

imagecopyresampled(
$img,
$this->mergeImage->getImageResource(),
$this->centerX,
$this->centerY,
Expand All @@ -120,6 +136,8 @@ public function merge($percentage)
$this->mergeImageHeight
);

$this->sourceImage->setImageResource($img);

return $this->createImage();
}

Expand Down

0 comments on commit 082ad12

Please sign in to comment.