Including qrencode generated QR codes in a PDF using prawn / ruby

I’m porting an old app into docker, and trying to avoid using stuff where the end of life has been and gone so I’ve updated ruby, and the version of linux they were using. And now I find that reason prawn doesn’t render qrencode generated QR codes any more. I think it might be because qrencode adds an alpha channel to the border of the png.

Install imagemagick and inspect a qrencode png which doesn’t work:

Colorspace: sRGB
...
Background color: white
Border color: srgba(223,223,223,1)
Matte color: grey74
Transparent color: none

Whereas if run the same png through imagemagick with convert test.png newtest.png:

Colorspace: Gray
...
Background color: gray(255)
Border color: gray(223)
Matte color: gray(189)
Transparent color: gray(0)

Causes newtest.png to render in your prawn pdf.

Leave a Reply

Your email address will not be published. Required fields are marked *