Skip to content
Advertisement

How to write text with opacity on a picture in PHP?

I’m writing a text on a picture. So far everything is fine, but I have to lower the transparency or opacity value of this text. I tried the following methods for the opacity value, but I couldn’t get any results.

JavaScript

Actual result : https://prnt.sc/vy8axf

Expected result : https://prnt.sc/vy8cnz

Advertisement

Answer

You could use imagecolorallocatealpha() to assign alpha channel to $textcolor :

JavaScript

Ex:

JavaScript

Note that :

A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement