Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write (semi)-transparent/clouded text #147

Open
Geolim4 opened this issue Feb 15, 2018 · 0 comments
Open

Write (semi)-transparent/clouded text #147

Geolim4 opened this issue Feb 15, 2018 · 0 comments

Comments

@Geolim4
Copy link

Geolim4 commented Feb 15, 2018

Just for the sharing:

If you want to write semi-transparent text, instead of passing hexa color to write(), you can pass an imagecolorallocatealpha ressource:

Classic text:

$image->write(
	'myfont.ttf',
	'mytext',
	10,
	290,
	'10',
	'0',
	'666666',
	'left'
);

Transparent text (with custom opacity from 0 to 127):

$opacity = 100; // from 0 to 127
$image->write(
	'myfont.ttf',
	'mytext',
	10,
	290,
	'10',
	'0',
        imagecolorallocatealpha(imagecreatetruecolor(IMAGE_WIDTH, IMAGE_HEIGHT), 0, 0, 0, $opacity),
	'left'
);

See imagecolorallocatealpha()

Hope this will help some people.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant