dealfonso / sapp

Simple and Agnostic PDF Document Parser in PHP - sign PDF docs using PHP
GNU Lesser General Public License v3.0
118 stars 31 forks source link

PNG with transparent bg only shows an empty rectangle #33

Closed erikn69 closed 1 year ago

erikn69 commented 1 year ago

I'm generating a QR Code using milon/barcode, but when i use that png on the signature the image is not showing, if i manually change the same image to jpg it works

Does this package supports png transparency?

Generated QR Code:

test

parallels999 commented 1 year ago

I did find an alpha flag here 'alpha' => $add_alpha, but seems like it is never used, maybe the problem is there https://github.com/dealfonso/sapp/blob/7782f7f969268c877b9478f388ac8d5a19be2a33/src/helpers/contentgeneration.php#L267

dealfonso commented 1 year ago

Hi, the problem seems to be with the type of image. Your image is a 1-bit PNG

$ file transparent.png
transparent.png: PNG image data, 126 x 126, 1-bit colormap, non-interlaced

If you convert it to a 8-bit image, it works as expected

$ convert transparent.png transparent2.png
$ file transparent2.png
transparent2.png: PNG image data, 126 x 126, 8-bit gray+alpha, non-interlaced
image
dealfonso commented 1 year ago

It seems to be related to PDF documents: if I insert your original image using Adobe Acrobat, it appears without transparency, but if I insert the converted one, it appears as expected:

image
erikn69 commented 1 year ago

That is weird, on fpdf that image works

I'm using image.intervention for image convert and now it works with transparence