Bacon / BaconQrCode

QR Code Generator for PHP
BSD 2-Clause "Simplified" License
1.82k stars 208 forks source link

Alpha generating an all blank qr code. #138

Closed marcosfreitas closed 5 months ago

marcosfreitas commented 1 year ago

php 8 with imagick.

I have these parameters and If I use the alpha, the generated qr code remains blank, ignoring the colors. Any suggestion?

foreground color:

array (
    'r' => 255,
    'g' => 16,
    'b' => 16,
    'a' => 1,
  )

background-color:

array (
    'r' => 0,
    'g' => 255,
    'b' => 91,
    'a' => 1,
  ),

base64 result:

iVBORw0KGgoAAAANSUhEUgAAAcIAAAHCAgMAAAABdiHWAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAJUExURYCHNQD/W////5BFhoQAAAACdFJOUwUDku1oxwAAAAFiS0dEAmYLfGQAAAJQSURBVHja7dxLrusgDADQdBHZVybsfytPb3A/bR1syEdX6mFURYEDncRgJ8vSb4/2u31fSX4caUQikUgkEv+MmAw7IT4vpLKi/21L/od4QCKRSCQSiV2x+ugfunmPyAYZWj6RSCQSicSLxF7fuV4HxPUr4FnD5ROJRCKRSLxXPD/OeV5INfIhEolEIpF4wa786Yl/OBeQTDsTz8+wEIlEIpH4aWKlJnCobvCiKsT76x6JRCKRSCQOTabbWrE9hzdrm20bkUgkEonEZJyx7f/yNoet+qMudroQiUQikUi8TRyKAfbmmdQzbNVDjxaKjyDfQSQSiUQisSNekvSPeh0Uh+oSf05XiEQikUgkLtGXhW4WOycbLalgXPev9PIdRCKRSCQSy2IcLRxIE7zUBHbGT64MZkmIRCKRSCQmZQCVwoDzxDRPEcYw89MjEolEIpFYE+OT/464VKOC3vFC9h2k6oSj7AORSCQSicREHA9IKsUDQQzQ4grGNTwPeV/sI0tzEIlEIpFIrIjbSJnfbD1AJ5g5U3wZkEgkEolE4kFxvL0M2Aqtk8uIDzTa/hUikUgkEomVY/z69v+i7xWXF0IkEolEIvFWcTkjXzCUwnhPhQxVS25EIpFIJBJ74tyjPw4GdnIBk2JLrhCJRCKRSLxajEerxADbklQXVE4tsjcm4nuIRCKRSCSeK85VEQyKbb9AsbJYIpFIJBKJR8Xyrr8eJFTKHdf+2wrZycNazrAQiUQikfiJYmVHP9H3QHjQyVysbfeDCWOvPBCJRCKR+NHiP9uNgCxWxGyIAAAAAElFTkSuQmCC

rendered:

image

marcosfreitas commented 1 year ago

I could fix this by multiplying the alpha value by 100 before generating the qr code. It only happened in PHP 8.

DASPRiD commented 1 year ago

That sounds a lot like a bug in a specific version of the IMagick library. Best to report the bug there. What we are passing in for RGB is the following:

rgba(%d, %d, %d, %F): https://github.com/Bacon/BaconQrCode/blob/master/src/Renderer/Image/ImagickImageBackEnd.php#L307

With the alpha value being set between 0 and 1, as documented.

DASPRiD commented 5 months ago

Actually, you are supposed to pass in the alpha value as 0-100, not 0-1 :)