Skip to content

Commit

Permalink
Added an exception to allow non alpha png files written, if alpha cha…
Browse files Browse the repository at this point in the history
…nnel is set to 0. An alpha channel is only added, if this value is between 1 and 127 (higher value than 127 is not allowed by php).
  • Loading branch information
Huseriato authored and Huseriato committed Aug 18, 2020
1 parent 8605e2c commit 15c28af
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Writer/PngWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ private function createInterpolatedImage($baseImage, array $data, QrCodeInterfac
$backgroundColor = imagecolorallocatealpha($image, $qrCode->getBackgroundColor()['r'], $qrCode->getBackgroundColor()['g'], $qrCode->getBackgroundColor()['b'], $qrCode->getBackgroundColor()['a']);
imagefill($image, 0, 0, $backgroundColor);
imagecopyresampled($image, $baseImage, (int) $data['margin_left'], (int) $data['margin_left'], 0, 0, (int) $data['inner_width'], (int) $data['inner_height'], imagesx($baseImage), imagesy($baseImage));
imagesavealpha($image, true);

if($qrCode->getBackgroundColor()['a'] > 0)
imagesavealpha($image, true);

return $image;
}
Expand Down

0 comments on commit 15c28af

Please sign in to comment.