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

Can I able to use transparent background image? #12

Open
hanmyohtwe opened this issue Apr 17, 2017 · 2 comments
Open

Can I able to use transparent background image? #12

hanmyohtwe opened this issue Apr 17, 2017 · 2 comments

Comments

@hanmyohtwe
Copy link

I would like to use transparent "countdown.png" instead of white color. Will it be possible?

@jakeanspach
Copy link

@hanmyohtwe Were you able to figure this out?

@kriptoblak
Copy link

kriptoblak commented Aug 4, 2019

I would like to use transparent "countdown.png" instead of white color. Will it be possible?
https://stackoverflow.com/a/17016252/7892190

$image = imagecreatefrompng('images/transparentimage.png');
$width  = imagesx($image);
$height = imagesy($image);
$imageOut     = imagecreatetruecolor($width, $height);
$background = imagecolorallocatealpha($imageOut, 0, 0, 0, 0);
imagefill($imageOut, 0, 0 , $background);
imagecopyresampled($imageOut, $image, 0, 0, 0, 0, $width, $height,  $width, $height);
imagesavealpha($imageOut, true);
imagecolortransparent($imageOut, $background);

Modify the next line

imagettftext ($imageOut , $font['size'] , $font['angle'] , $font['x-offset'] , $font['y-offset'] , $font['color'] , $font['file'], $text );

$font['color'] has to be imagecolorallocatealpha($imageOut, 51, 102, 255, 0) (any color) and should NOT be black like the $background imagecolorallocatealpha($imageOut, 0, 0, 0, 0). Black will become transparent.

Modify the next line

imagegif($imageOut);

Or you can maybe play with the

$transparent_colour_red = 0;
$transparent_colour_green = 0;
$transparent_colour_blue = 0;

in GIFEncoder.class.php

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

3 participants