Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert PNG with alpha channel using FPDF (PHP)

Tags:

php

png

fpdf

In official documentation of FPDF, it said alpha channel is not supported for PNG.

Is there any workaround?

like image 343
Raptor Avatar asked Dec 17 '22 00:12

Raptor


1 Answers

If you need to put a transparent image on top of another: use PHPs build in functions to copy one image onto the other one. Then you will end up with a new picture, containing boths images. Save as a non-alpha png, and insert.

There's an example here of the code needed to combine the images.

If you want text to be visible under you picture: insert the picture first, then write you text into the document.

like image 157
qualbeen Avatar answered Jan 02 '23 07:01

qualbeen