Hi,
i got a problem with the gd library at my isp's server.
I've got the following script, to put a string on a image:
<?PHP
header ("Content-type: image/png");
$gd_text = $_GET['stadt'];
$font = "/home/stadt-internetde/public_html/bilder/ariblk.ttf";
//"ariblk.ttf"; ;
$x = imagettfbbox (23, 0, $font, $_GET['stadt']);
if((154 + ($x['2']-$x['0'])+12) < 281) $breite = 281; else $breite = 154 +
($x['2']-$x['0']+12);
$im = ImageCreate($breite ,173);
$im2 = ImageCreateFromJPEG("logo.jpg");
$orange = ImageColorAllocate ($im, 220, 167, 23);
$blau = ImageColorAllocate ($im, 51, 102, 153);
$bgc = ImageColorAllocate ($im, 255, 255, 255);
ImageFilledRectangle ($im, 0, 0, ImageSX($im), ImageSY($im), $bgc);
ImageCopyResized($im, $im2, 0, 0, 0, 0, 281, 173, ImageSX($im2),
ImageSY($im2));
//border -----
$test = ImageTTFText ($im, 23, 0, 154, 58, $blau, $font, $gd_text);
$test = ImageTTFText ($im, 23, 0, 154, 56, $blau, $font, $gd_text);
$test = ImageTTFText ($im, 23, 0, 156, 56, $blau, $font, $gd_text);
$test = ImageTTFText ($im, 23, 0, 156, 58, $blau, $font, $gd_text);
//text --------
$test = ImageTTFText ($im, 23, 0, 155, 57, $orange, $font, $gd_text);
ImageColorTransparent($im , $bgc);
ImagePNG ($im);
ImageDestroy($im);
?>
On my localhost, everything works fine, but on the internetserver, the
created image is very ugly!
On the internet-server i got gd-version 2.0 or higher, so i tried to change
$im = ImageCreate($breite ,173);
to
$im = ImageCreateTrueColor($breite ,173);
but when I use ImageCreateTrueColor the transparency is gone and the image
is still ugly!
Phpinfo shows:
gd support enabled
gd version 2.0 or higher
Freetype support enabled
Freetype linkage with Freetype
JPG support enabled
PNG support enabled
wbmp support enabled
Anyone got an idea for me?
mfg.
Harry Wiens
i got a problem with the gd library at my isp's server.
I've got the following script, to put a string on a image:
<?PHP
header ("Content-type: image/png");
$gd_text = $_GET['stadt'];
$font = "/home/stadt-internetde/public_html/bilder/ariblk.ttf";
//"ariblk.ttf"; ;
$x = imagettfbbox (23, 0, $font, $_GET['stadt']);
if((154 + ($x['2']-$x['0'])+12) < 281) $breite = 281; else $breite = 154 +
($x['2']-$x['0']+12);
$im = ImageCreate($breite ,173);
$im2 = ImageCreateFromJPEG("logo.jpg");
$orange = ImageColorAllocate ($im, 220, 167, 23);
$blau = ImageColorAllocate ($im, 51, 102, 153);
$bgc = ImageColorAllocate ($im, 255, 255, 255);
ImageFilledRectangle ($im, 0, 0, ImageSX($im), ImageSY($im), $bgc);
ImageCopyResized($im, $im2, 0, 0, 0, 0, 281, 173, ImageSX($im2),
ImageSY($im2));
//border -----
$test = ImageTTFText ($im, 23, 0, 154, 58, $blau, $font, $gd_text);
$test = ImageTTFText ($im, 23, 0, 154, 56, $blau, $font, $gd_text);
$test = ImageTTFText ($im, 23, 0, 156, 56, $blau, $font, $gd_text);
$test = ImageTTFText ($im, 23, 0, 156, 58, $blau, $font, $gd_text);
//text --------
$test = ImageTTFText ($im, 23, 0, 155, 57, $orange, $font, $gd_text);
ImageColorTransparent($im , $bgc);
ImagePNG ($im);
ImageDestroy($im);
?>
On my localhost, everything works fine, but on the internetserver, the
created image is very ugly!
On the internet-server i got gd-version 2.0 or higher, so i tried to change
$im = ImageCreate($breite ,173);
to
$im = ImageCreateTrueColor($breite ,173);
but when I use ImageCreateTrueColor the transparency is gone and the image
is still ugly!
Phpinfo shows:
gd support enabled
gd version 2.0 or higher
Freetype support enabled
Freetype linkage with Freetype
JPG support enabled
PNG support enabled
wbmp support enabled
Anyone got an idea for me?
mfg.
Harry Wiens
Kommentar