Black background on GIF instead of transparency in PHP using imagegif() - php

Edit 2:
SUCCESS! many thanks to moycakes!
The correct way to convert a PNG to a GIF while retaining transparency goes as follows:
$input = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXwAAAEYCAYAAABfgk2GAAAemklEQVR4Xu2dzYsm13WHe7rHxGATtw1Zu8UMY0wIkv6AoF44ZOEspFWyUytkkRASJG0sgS2NPkCKF5qxMSSboNbOu4xJcAxZaJRNlhqRVYaZpPUPSC2wiYmm38k5rS75delW1b1V9+Pcuk9BMR/vrXvPfc6p33veU7eqLu2wQQACEIBAEwQuNTFLJgkBCEAAAjsIPkEAAQhAoBECCH4jjmaaEIAABBB8YgACEIBAIwQQ/EYczTQhAAEIIPjEAAQgAIFGCCD4jTiaaUIAAhBA8IkBCEAAAo0QQPAbcTTThAAEIIDgEwMQgAAEGiGA4DfiaKYJAQhAAMGvJwYeE1OfkP3JC5P3L/48vfjzlvz5nux36pkSlkIAAjkJIPg5ac8b60gOe1n2A8/DT6Tdddnf8WxPMwhAoBECCL5dRx+KaW8HCH1/Jir8T5Hx23UwlkEgNwEEPzdxv/E0q1exj7E9I50cx+iIPiAAgboJIPj2/Kfi/HRks7RPFX62dRLg+s46/Rp9Vgh+dKSLOoyZ2fcNIdNf5BqTB2u8cH3HpGtsGoXg2/HLoZjybmJzHpf+WcWTGHKG7jVWuL6TAfTahkDw7Xj0REz5ZmJzdIxHEo9B92kJxPwVyK++tL4y1zuCb8MlMU/iqRn9nTR4YaoRn5skcCxWcX3HpGvqMArBt+GnHNl9N9ON/GXPxrSxIoBAyqSATD/AETU3RfDLe09XWLyf2Qxq+ZmBLxzuUI7n+s5CiBy+w0vMDQTBs2LDjcx2PCfj3cw8JsPNJ5DjF6COwfWd+T6q4kgy/PJuui0m6DNycm76zB3NGtnsEzgSE2PdhDc1W0o7U4Qq/xzBL+9ABL+8DyxbkCO77+ZPlm85EiLYhuBHgLiwC10X/+jCPkIP1zG1js9mmwDXd2z7pzrrEPzyLish+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d7yrpdK2Unz7vhi0+gZAs36SOxUeyvEfToM6z/R0RSN8XnJ8L/d71a6f3Mwvq+asQRVA1a9dt70JQzy4EdU8E9UwENXlGvzwi6MFFQP2pWafu28+nafXehBxRguAnoGxa8Lv56h25e5Khnu1cPhdUiYRzQRXjzwV1b+fBrTPJUNNn9Ak8QJc1EdgWfrV7e2VJTfOowdaQsk4VOmYBOqAseAEbIACBIQI+mT465hk/gPIERTMIQKAIgalMn1U6AW5B8ANg0RQCEIBAzQQQ/Jq9h+0QgAAEAggg+AGwaAoBCECgZgIIfs3ew3YIQAACAQQQ/ABYNIUABCBQMwEEv2bvYTsEIACBAAIIfgAsmkIAAhComQCCX7P3sB0CEIBAAAEEPwAWTSEAAQjUTADBr9l72A4BCEAggACCHwCLphCAAARqJoDg1+w9bIcABCAQQADBD4BFUwhAAAI1E0Dwa/YetkMAAhAIIIDgB8CiKQQgAIGaCSD4NXsP2yEAAQgEEEDwA2DRFAIQgEDNBBD8mr2H7RCAAAQCCCD4AbBoCgEIQKBmAgh+zd7DdghAAAIBBBD8AFg0hQAEIFAzAQS/Zu9hOwQgAIEAAgh+ACyaQgACEKiZAIJfs/ewHQIQgEAAAQQ/ABZNIQABCNRMAMGv2XvYDgEIQCCAAIIfAIumEIAABGomgODX7D1shwAEIBBAAMEPgEVTCEAAAjUTQPBr9h62QwACEAgggOAHwKIpBCAAgZoJIPg1ew/bIQABCAQQQPADYNEUAhCAQM0EEPyavYftEIAABAIIIPgBsGgKAQhAoGYCCH7N3sN2CEAAAgEEEPwAWDSFAAQgUDMBBL9m72E7BCAAgQACCH4ALJpCAAIQqJkAgl+z97AdAhCAQAABBD8AFk0hAAEI1Ezg/wFm7lJkZahzkgAAAABJRU5ErkJggg==";
$image = imagecreatefrompng($input);
imagesavealpha($image, true);
imagecolortransparent($image, 127<<24);
imagegif($image, 'img/test.gif');
GOSH! two days for such a simple few lines of code >__<
Thank you to everyone who posted a suggestion.
old post:
Alright, I'm at my wits end now. (Why is the GD library in PHP so confusing??)
I've been at this for several hours two days now.. and I just can't get PHP to make a GIF from a PNG with a transparent background.
There are several posts about this on StackOverflow but none of the solutions provided really helped me at all. I always end up with either a black background image or everything black in my image becomes transparent except for the background (or just everything stays black).
I've typed imagecolorallocate and imagecolortransparent so many times that these commands have lost their meaning to me.. >___<
my code looks like this:
$input = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXwAAAEYCAYAAABfgk2GAAAemklEQVR4Xu2dzYsm13WHe7rHxGATtw1Zu8UMY0wIkv6AoF44ZOEspFWyUytkkRASJG0sgS2NPkCKF5qxMSSboNbOu4xJcAxZaJRNlhqRVYaZpPUPSC2wiYmm38k5rS75delW1b1V9+Pcuk9BMR/vrXvPfc6p33veU7eqLu2wQQACEIBAEwQuNTFLJgkBCEAAAjsIPkEAAQhAoBECCH4jjmaaEIAABBB8YgACEIBAIwQQ/EYczTQhAAEIIPjEAAQgAIFGCCD4jTiaaUIAAhBA8IkBCEAAAo0QQPAbcTTThAAEIIDgEwMQgAAEGiGA4DfiaKYJAQhAAMGvJwYeE1OfkP3JC5P3L/48vfjzlvz5nux36pkSlkIAAjkJIPg5ac8b60gOe1n2A8/DT6Tdddnf8WxPMwhAoBECCL5dRx+KaW8HCH1/Jir8T5Hx23UwlkEgNwEEPzdxv/E0q1exj7E9I50cx+iIPiAAgboJIPj2/Kfi/HRks7RPFX62dRLg+s46/Rp9Vgh+dKSLOoyZ2fcNIdNf5BqTB2u8cH3HpGtsGoXg2/HLoZjybmJzHpf+WcWTGHKG7jVWuL6TAfTahkDw7Xj0REz5ZmJzdIxHEo9B92kJxPwVyK++tL4y1zuCb8MlMU/iqRn9nTR4YaoRn5skcCxWcX3HpGvqMArBt+GnHNl9N9ON/GXPxrSxIoBAyqSATD/AETU3RfDLe09XWLyf2Qxq+ZmBLxzuUI7n+s5CiBy+w0vMDQTBs2LDjcx2PCfj3cw8JsPNJ5DjF6COwfWd+T6q4kgy/PJuui0m6DNycm76zB3NGtnsEzgSE2Pd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vG7gc3pWHQikTo0Ceq8pr/z4Hj2e27lAq2kZU/Of2m5L93zbD9QUM+k/bXcgqp35B7Krlm7bt3qjy5D1TqqChcZ/Rdd7yrpdK2Unz7vhi0+gZAs36SOxUeyvEfToM6z/R0RSN8XnJ8L/d71a6f3Mwvq+asQRVA1a9dt70JQzy4EdU8E9UwENXlGvzwi6MFFQP2pWafu28+nafXehBxRguAnoGxa8Lv56h25e5Khnu1cPhdUiYRzQRXjzwV1b+fBrTPJUNNn9Ak8QJc1EdgWfrV7e2VJTfOowdaQsk4VOmYBOqAseAEbIACBIQI+mT465hk/gPIERTMIQKAIgalMn1U6AW5B8ANg0RQCEIBAzQQQ/Jq9h+0QgAAEAggg+AGwaAoBCECgZgIIfs3ew3YIQAACAQQQ/ABYNIUABCBQMwEEv2bvYTsEIACBAAIIfgAsmkIAAhComQCCX7P3sB0CEIBAAAEEPwAWTSEAAQjUTADBr9l72A4BCEAggACCHwCLphCAAARqJoDg1+w9bIcABCAQQADBD4BFUwhAAAI1E0Dwa/YetkMAAhAIIIDgB8CiKQQgAIGaCSD4NXsP2yEAAQgEEEDwA2DRFAIQgEDNBBD8mr2H7RCAAAQCCCD4AbBoCgEIQKBmAgh+zd7DdghAAAIBBBD8AFg0hQAEIFAzAQS/Zu9hOwQgAIEAAgh+ACyaQgACEKiZAIJfs/ewHQIQgEAAAQQ/ABZNIQABCNRMAMGv2XvYDgEIQCCAAIIfAIumEIAABGomgODX7D1shwAEIBBAAMEPgEVTCEAAAjUTQPBr9h62QwACEAgggOAHwKIpBCAAgZoJIPg1ew/bIQABCAQQQPADYNEUAhCAQM0EEPyavYftEIAABAIIIPgBsGgKAQhAoGYCCH7N3sN2CEAAAgEEEPwAWDSFAAQgUDMBBL9m72E7BCAAgQACCH4ALJpCAAIQqJkAgl+z97AdAhCAQAABBD8AFk0hAAEI1Ezg/wFm7lJkZahzkgAAAABJRU5ErkJggg==";
list($ignore, $imgData) = explode(',', $input);
$image = imagecreatefromstring(base64_decode($imgData));
imagealphablending($image, true); // setting alpha blending on
imagesavealpha($image, true); // save alphablending setting
//my code works up until this point (I can output a transparent PNG successfully)
//this is where I would make a new image with-
//the transparent background and put my transparent PNG on it-
//to prep it for imagegif();
//i kinda had some success with:
//$fill = imagecolorallocate($image, 255, 250, 214);
//imagefill($image, 0, 0, $fill);
//just to test if I could actually change the background..
//but anything like a circle with a transparent center would not--
//get filled with transparency and would remain black.
//so this obviously isn't the way to do it.
imagegif($img, 'test.gif');
The end result has to be a GIF preserving the PNG's transparent background.
I'm really stuck ¬____¬ please help me.
Thank you in advance for any advice you can provide.
Edit:
To show you an example of why chrislondon's second example does not work, I have drawn a half circle and a full circle in this image and then spun it through chrislondon's code (resulting in a .GIF image which is what I want):
The (lumpy)black circle is not filled by me, it is just the transparency in the center not showing through. The (lumpy)circle to the right is not completed all the way leaving a gap and so the transparency is filled.
I hope this will clear up any remaining misunderstandings to what I'm trying to achieve.

imagecolortransparent($image, 127<<24); // 0x7f000000
The GD library stores the alpha in a weird way.
0x7f000000 = 100% transparent black
0x00000000 = 100% opaque black
So choosing the transparent black, over the opaque black color, will make it transparent.

This appears to work:
$input = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXwAAAEYCAYAAABfgk2GAAAemklEQVR4Xu2dzYsm13WHe7rHxGATtw1Zu8UMY0wIkv6AoF44ZOEspFWyUytkkRASJG0sgS2NPkCKF5qxMSSboNbOu4xJcAxZaJRNlhqRVYaZpPUPSC2wiYmm38k5rS75delW1b1V9+Pcuk9BMR/vrXvPfc6p33veU7eqLu2wQQACEIBAEwQuNTFLJgkBCEAAAjsIPkEAAQhAoBECCH4jjmaaEIAABBB8YgACEIBAIwQQ/EYczTQhAAEIIPjEAAQgAIFGCCD4jTiaaUIAAhBA8IkBCEAAAo0QQPAbcTTThAAEIIDgEwMQgAAEGiGA4DfiaKYJAQhAAMGvJwYeE1OfkP3JC5P3L/48vfjzlvz5nux36pkSlkIAAjkJIPg5ac8b60gOe1n2A8/DT6T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BoCgEIQKBmAgh+zd7DdghAAAIBBBD8AFg0hQAEIFAzAQS/Zu9hOwQgAIEAAgh+ACyaQgACEKiZAIJfs/ewHQIQgEAAAQQ/ABZNIQABCNRMAMGv2XvYDgEIQCCAAIIfAIumEIAABGomgODX7D1shwAEIBBAAMEPgEVTCEAAAjUTQPBr9h62QwACEAgggOAHwKIpBCAAgZoJIPg1ew/bIQABCAQQQPADYNEUAhCAQM0EEPyavYftEIAABAIIIPgBsGgKAQhAoGYCCH7N3sN2CEAAAgEEEPwAWDSFAAQgUDMBBL9m72E7BCAAgQACCH4ALJpCAAIQqJkAgl+z97AdAhCAQAABBD8AFk0hAAEI1Ezg/wFm7lJkZahzkgAAAABJRU5ErkJggg==";
list($ignore, $imgData) = explode(',', $input);
$image = imagecreatefromstring(base64_decode($imgData));
$width = imagesx($image);
$height = imagesy($image);
$imageOut = imagecreatetruecolor($width, $height);
//TODO - edges will be anti-aliased to this colour, pick one that will look
//'good' for you, e.g. mid-grey for general case, white for white pages,
$background = imagecolorallocatealpha($imageOut, 0x7f, 0x7f, 0x7f, 0);
imagefill($imageOut, 0, 0 , $background);
imagecopyresampled($imageOut, $image, 0, 0, 0, 0, $width, $height, $width, $height);
imagesavealpha($imageOut, true);
imagecolortransparent($imageOut, $background);
imagegif($imageOut, "../../var/tmp/test.gif");
The bit you missed was you have to explicitly say which colour should be set as transparent. It won't automatically convert the alpha channel to being transparent.
However this method is actually slightly dangerous, as whichever pixels are that colour will be transparent in the final image. You may be better choosing a colour unlikely to be present elsewhere e.g. rgb(0xff, 0xff, 0)

If you're fine with a PNG this works perfectly:
$input = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXwAAAEYCAYAAABfgk2GAAAemklEQVR4Xu2dzYsm13WHe7rHxGATtw1Zu8UMY0wIkv6AoF44ZOEspFWyUytkkRASJG0sgS2NPkCKF5qxMSSboNbOu4xJcAxZaJRNlhqRVYaZpPUPSC2wiYmm38k5rS75delW1b1V9+Pcuk9BMR/vr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AoBCECgZgIIfs3ew3YIQAACAQQQ/ABYNIUABCBQMwEEv2bvYTsEIACBAAIIfgAsmkIAAhComQCCX7P3sB0CEIBAAAEEPwAWTSEAAQjUTADBr9l72A4BCEAggACCHwCLphCAAARqJoDg1+w9bIcABCAQQADBD4BFUwhAAAI1E0Dwa/YetkMAAhAIIIDgB8CiKQQgAIGaCSD4NXsP2yEAAQgEEEDwA2DRFAIQgEDNBBD8mr2H7RCAAAQCCCD4AbBoCgEIQKBmAgh+zd7DdghAAAIBBBD8AFg0hQAEIFAzAQS/Zu9hOwQgAIEAAgh+ACyaQgACEKiZAIJfs/ewHQIQgEAAAQQ/ABZNIQABCNRMAMGv2XvYDgEIQCCAAIIfAIumEIAABGomgODX7D1shwAEIBBAAMEPgEVTCEAAAjUTQPBr9h62QwACEAgggOAHwKIpBCAAgZoJIPg1ew/bIQABCAQQQPADYNEUAhCAQM0EEPyavYftEIAABAIIIPgBsGgKAQhAoGYCCH7N3sN2CEAAAgEEEPwAWDSFAAQgUDMBBL9m72E7BCAAgQACCH4ALJpCAAIQqJkAgl+z97AdAhCAQAABBD8AFk0hAAEI1Ezg/wFm7lJkZahzkgAAAABJRU5ErkJggg==";
$image = imagecreatefrompng($input);
imagesavealpha($image, true);
imagepng($image, 'test.png');
If you want to convert it to a GIF you have to fill in the transparent color like this:
$input = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXwAAAEYCAYAAABfgk2GAAAemklEQVR4Xu2dzYsm13WHe7rHxGATtw1Zu8UMY0wIkv6AoF44ZOEspFWyUytkkRASJG0sgS2NPkCKF5qxMSSboNbOu4xJcAxZaJRNlhqRVYaZpPUPSC2wiYmm38k5rS75delW1b1V9+Pcuk9BMR/vrXvPfc6p33veU7eqLu2wQQACEIBAEwQuNTFLJgkBCEAAAjsIPkEAAQhAoBECCH4jjmaaEIAABBB8YgACEIBAIwQQ/EYczTQhAAEIIPjEAAQgAIFGCCD4jTiaaUIAAhBA8IkBCEAAAo0QQPAbcTTTh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BD4BFUwhAAAI1E0Dwa/YetkMAAhAIIIDgB8CiKQQgAIGaCSD4NXsP2yEAAQgEEEDwA2DRFAIQgEDNBBD8mr2H7RCAAAQCCCD4AbBoCgEIQKBmAgh+zd7DdghAAAIBBBD8AFg0hQAEIFAzAQS/Zu9hOwQgAIEAAgh+ACyaQgACEKiZAIJfs/ewHQIQgEAAAQQ/ABZNIQABCNRMAMGv2XvYDgEIQCCAAIIfAIumEIAABGomgODX7D1shwAEIBBAAMEPgEVTCEAAAjUTQPBr9h62QwACEAgggOAHwKIpBCAAgZoJIPg1ew/bIQABCAQQQPADYNEUAhCAQM0EEPyavYftEIAABAIIIPgBsGgKAQhAoGYCCH7N3sN2CEAAAgEEEPwAWDSFAAQgUDMBBL9m72E7BCAAgQACCH4ALJpCAAIQqJkAgl+z97AdAhCAQAABBD8AFk0hAAEI1Ezg/wFm7lJkZahzkgAAAABJRU5ErkJggg==";
$image = imagecreatefrompng($input);
$transparent = imagecolorallocatealpha($image, 255, 255, 255, 127);
imagefill($image, 0, 0, $transparent);
imagegif($image, 'test.gif');
Note that because your string is an image/png you can use imagecreatefrompng and not have to do any comma exploding :)

Try this:
list($ignore, $imgData) = explode(',', $input);
$image = imagecreatefromstring(base64_decode($imgData));
$fill = imagecolorallocate($image, 255, 250, 214);
imagecolortransparent($image, $fill);
imagefill($image, 0, 0, $fill);
imagegif($image);

Related

Create transparent png of given text

I would like to create a transparent png of some given text. I don't want to specify the width and height of the image, but have it automatically size to the size of the text. I've experimented with both imagemagick and PHP, however, haven't quite got it. How would I do so using either of these technologies, or any other technology? Also, why is one technology better than the other?
imagemagick solution
Works, except requires size of image to be specified instead of automatically sizing to text size.
convert -size 560x85 xc:transparent -font Palatino-Bold -pointsize 72 -fill black -stroke red -draw "text 20,55 'Linux and Life'" linuxandlife.png
PHP Solution
Works except chops a bit off the right side. Also, if I make multiple images with text of the same font size and font type, and they all have capital letters in them, the height of the images are not all the same, yet I would have expected them to have been the same. Also, just played with image functions for the first time today, and please let me know if I am doing anything else incorrect.
<?php
$font_size = 11;
$angle=0;
//$fonttype="/usr/share/fonts/liberation/LiberationMono-Regular.ttf";
$fonttype="/usr/share/fonts/dejavu/DejaVuSans.ttf";
$text='Some text';
$file='MyFile.png';
$bbox = imagettfbbox($font_size, $angle, $fonttype, $text);
$x1 = $bbox[2] - $bbox[0];
$y1 = $bbox[1] - $bbox[7];
$im = #imagecreatetruecolor($x1, $y1);
imagesavealpha($im, true);
imagealphablending($im, false);
$color_background = imagecolorallocatealpha($im, 255, 255, 255, 127);
imagefill($im, 0, 0, $color_background);
$color_text = imagecolorallocate($im, 255, 0, 0);
imagettftext($im, $font_size, $angle, 0, $font_size, $color_text, $fonttype, $text);
imagepng($im,$file);
imagedestroy($im);
?>
I would choose the pure php solution, so you are not depended on external libs like imagemagick.
Maybe it wohl be a good idea if you would use browser caching, so you don`t ne to generate the images on every request.
Yust add the following code before your 'imagettfbbox' and put your image generation code in the ELSE.
$string = $text . filemtime($file);
$eTag = md5($string);
header("ETag: ".$eTag);
$httpModEtag = !empty($_SERVER['HTTP_IF_NONE_MATCH'])? $_SERVER['HTTP_IF_NONE_MATCH']:"";
if($httpModEtag===$eTag)
{
// tells the browser to use his cached image
header("HTTP/1.1 304 Not Modified", true, 304);
}
else
{
// tells the browser to refresh the cache
header("Cache-Controll: must-revalidate");
// ------ Place your Image Generation code here -------
}

PHP/GD - transparent background

I want to do the following in PHP in combination with GD. ImageMagick is not an option, unfortunately, but this seems like such a common problem that there has to be a solution, I just can't seem to find it.
I want to create a PNG with a transparent background. Then I want to draw a rectangle on it, copy an image on it, and add some text. One way of doing this is as follows:
$image = ImageCreateTrueColor (800, 600);
imagecolortransparent ($image, 0); //0 is pure black, the default fill color
imagerectangle (...);
//code to copy an image
imagettftext ($image, ...);
imagepng ($image);
This works fine, except that part of the copied image might be black, and/or the text might be black. This then also becomes transparent, which is something I don't want.
imagefill ($image, 0,0, 0x7FFF0000);
imagetransparent ($image, 0x7FFF0000);
The above code is something I found online, which fills it with red, then makes red transparent. Again, this causes all red in the image to become transparent. I could choose a color that is unlikely to occur, but I can't guarantee this.
Is there something I'm missing? Can this be fixed?
Thanks for your replies!
imagecolortransparent is probably not what you want here if you're merging images, as single-colour transparency is nasty.
Instead, try it with a transparent fill mask like so:
<?php
$image = imagecreatetruecolor(100, 100);
// Transparent Background
imagealphablending($image, false);
$transparency = imagecolorallocatealpha($image, 0, 0, 0, 127);
imagefill($image, 0, 0, $transparency);
imagesavealpha($image, true);
// Drawing over
$black = imagecolorallocate($image, 0, 0, 0);
imagefilledrectangle($image, 25, 25, 75, 75, $black);
header('Content-Type: image/png');
imagepng($image);

imagepng and imagegif

I need some help about PHP GD. Here is my piece of code.
header("Content-type: image/gif");
$image = imagecreatetruecolor(550, 20);
imagealphablending($image, false);
$col=imagecolorallocatealpha($image,255,255,255,127);
$black = imagecolorallocate($image, 0, 0, 0);
imagefilledrectangle($image,0,0,550,20,$col);
imagealphablending($image, true);
$font_path = 'font/arial.ttf';
imagettftext($image, 9, 0, 16, 13, $black, $font_path, $lastlisten);
imagesavealpha($image, true);
imagepng($image);
The problem is when I use imagepng, it can show the png just fine like this.
But if I use imagegif instead, it will become this.
I did tried using different header for gif and png. The result for imagegif is still the same.
The question is how do I make in order to display GIF version properly? Thanks you
GIF image supports a maximum of 256 colors. Most importantly, it only supports index transparency: a pixel can be 100% opaque or 100% transparent.
PNG on the other hand supports true (millions of) color images and supports alpha channel transparency. That means a pixel can be 100% opaque, 100% transparent or anything in between.
The PNG image you mentioned probably has its edges partially transparent therefore the browser can easily blend those pixels with the background color giving a smooth effect. PNG is a better choice.
First problem : your characters are ugly: that's because you need to set a palette with less colors when using imagecreatetruecolor.
$image = imagecreatetruecolor(550, 20);
imagetruecolortopalette($image, true, 256);
should solve this problem.
Second problem : there is no transparency.
As you can see on PHP manual,
imagesavealpha() sets the flag to attempt to save full alpha channel
information (as opposed to single-color transparency) when saving PNG
images.
This function does not work with GIF files.
You can use imagecolortransparent instead but this will not be perfect because fonts has anti-aliasing to make their border sweeter.
Here is my code:
<?php
$lastlisten = "test test test test test test";
error_reporting(E_ALL);
header("Content-type: image/gif");
$image = imagecreatetruecolor(550, 20);
imagetruecolortopalette($image, true, 256);
$transparent=imagecolorallocatealpha($image,255,255,255,127);
imagecolortransparent( $image, $transparent);
imagefilledrectangle($image,0,0,550,20,$transparent);
$black = imagecolorallocate($image, 0, 0, 0);
$font_path = dirname(__FILE__) . '/font.ttf';
imagettftext($image, 9, 0, 16, 13, $black, $font_path, $lastlisten);
imagegif($image);
Result here
Hope this helps.

Merging Images using GD with PHP

i'm working on creating one PNG image from two others.
Image A and B have the same dimensions, they are both 200x400px. The final image the same.
I'm using the GD library with PHP.
So my idea was to create a PNG-24 from my original PNG-8, then use color transparency and finally copy the second image into
this new PNG-24. The problem appears in the first step anyway, when going from PNG-24 to PNG-8 with color transparency:
This is to get the original PNG-8 and it's dimensions:
$png8 = imagecreatefrompng($imageUrl);
$size = getimagesize($imageUrl);
Now i create a new PNG and fill it's background with a green color (not present in the images):
$png24 = imagecreatetruecolor($size[0], $size[1]);
$transparentIndex = imagecolorallocate($png24, 0x66, 0xff, 0x66);
imagefill($png24, 0, 0, $transparentIndex);
This is for making the green color transparent:
imagecolortransparent($png24, $transparentIndex);
Then i copy the png8 into the PNG-24:
imagecopy($png24, $png8, 0, 0, 0, 0, $size[0], $size[1]);
So here's the problem: the original PNG-8 looks good, but it has a green border surrounding the shape within the original image. It's difficult to explain really. Seems like some part of the green background is left in the remaining PNG.
What can i do?
thanks in advance
best regards,
Fernando
I had some problems with png transparency before and was able to solve them with this pattern:
// allocate original image to copy stuff to
$img = imagecreatetruecolor(200, 100);
// create second image
$bg = imagecreatefrompng('bg.png');
// copy image onto it using imagecopyresampled
imagecopyresampled($img, $bg, 0, 0, 0, 0, 200, 100, 200, 100);
imagedestroy($bg);
// create third image
// do same routine
$fg = imagecreatefrompng('fg.png');
imagecopyresampled($img, $fg, 50, 50, 0, 0, 50, 50, 50, 50);
imagedestroy($fg);
// output image
imagepng($img);
imagedestroy($img);
I think the only difference between mine and yours is imagecopy() vs. imagecopyresampled(). I seem to remember having problems with that though it was quite a while ago. You can see an example of an image I use this pattern on here: http://www.ipnow.org/images/1/bggrad/bg4/yes/TRANSIST.TTF/8B0000/custombrowserimage.jpg (I allocate a blank image, copy the background image in, copy the overlay with transparency in)

Set a color as transparent in palette-based image

I want to convert a alpha transparent png image to palette based png image.
In GD I can do it easy:
// We have already the image loaded in $source_img
$w=200; $h=200; // We supose that img dimensions are 200x200
$img = imagecreatetruecolor($w, $h); // New black image
list($r, $g, $b) = array(200, 200, 200); // Some color that doesn't appear in image to avoid conflict
$color = imagecolorallocate($img, $r, $g, $b);
imagefill($img, 0, 0, $color); // Fill the black image with the chosen color.
imagecolortransparent($img, $color); // Set the chosen color as transparent
$res = imagecopyresampled($img, $source_img, 0, 0, 0, 0, $w, $h, $w, $h);
But in Imagick I don't know how set a color as transparent (imagecolortransparent() in GD). I have spent hours searching on the internet, but the help in the php site isn't very comphrensive and there are many undocumented functions.
Thanks.
On the command line I would do something like this:
convert test.png -transparent-color white PNG8:converted.png
But there seems to be a problem in some IM versions with this type of conversion, I found this usergroup post by some guy who seems to have similiar problems: http://studio.imagemagick.org/pipermail/magick-users/2009-May/022534.html
Are you using the command line when working with IM or do you use the PHP module ( http://de.php.net/manual/en/book.imagick.php )?

Categories