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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.