Jump to content

PHP GD, distortion over text


pmiller624

Recommended Posts

Hello, I'm trying to create a simple 'not available' image with a dynamic width and height. My problem is that above the text, in the image, the colors get a little distorted/blurred.

 

I have attached an example of the problem...

 

Here's my code...

 

$width = $_GET['w'];
$height = $_GET['h'];  
$font = "arial.ttf";

$image = ImageCreate($width, $height);  

$white = ImageColorAllocate($image, 255, 255, 255);
$black = ImageColorAllocate($image, 0, 0, 0);
$grey = ImageColorAllocate($image, 204, 204, 204);
$background = ImageColorAllocate($image, 46, 46, 46);

ImageFill($image, 0, 0, $background); 

$box = @imageTTFBbox(11,0,$font,'NOT AVAILABLE YET');
imagettftext ( $image, 11, 0, $width/2-($box[4]/2), $height/2-($box[6]/2)+20, $grey, $font, 'NOT AVAILABLE YET' );
$box = @imageTTFBbox(15,0,$font,'?');
imagettftext ( $image, 15, 0, $width/2-($box[4]/2), $height/2-($box[6]/2), $grey, $font, '?' );

header("Content-Type: image/jpeg"); 

ImageJpeg($image);

ImageDestroy($image); 

 

Anyone know why this is happening?

 

Thanks

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/195954-php-gd-distortion-over-text/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.