Jump to content

Recommended Posts

Hi. 

 

I had a dynamic img creation with gdlib and Right Alignment.  I 'pinched' this script which worked well until my host upgraded to php5. Any ideas.  the following error messages are received.

 

‰PNG IHDR2ý~Ê

Warning: imagepng() [function.imagepng]: gd-png: fatal libpng error: zlib error in /home/clearcon/public_html/fonts/title.php on line 40

 

Warning: imagepng() [function.imagepng]: gd-png error: setjmp returns error condition in /home/clearcon/public_html/fonts/title.php on line 40

 

Heres the code

 

<?php
header("Content-type: image/png");
$text = str_replace("_"," ",$_GET['title']);
$font = "DAX-REGU.TTF";
$size = 22;
$angle = 0;


//check width of the text
$bbox = imagettfbbox ($size, $angle, $font, $text);
$bbox["left"] = 0- min($bbox[0],$bbox[2],$bbox[4],$bbox[6]);
$bbox["top"] = 0- min($bbox[1],$bbox[3],$bbox[5],$bbox[7]);
$bbox["width"] = max($bbox[0],$bbox[2],$bbox[4],$bbox[6]) - min($bbox[0],$bbox[2],$bbox[4],$bbox[6]);
$bbox["height"] = max($bbox[1],$bbox[3],$bbox[5],$bbox[7]) - min($bbox[1],$bbox[3],$bbox[5],$bbox[7]);
extract ($bbox, EXTR_PREFIX_ALL, 'bb');


//check width of the image
$insert = imagecreatetruecolor(400,50);
//choose textcolor (white)

$width = imagesx($insert);
$height = imagesy($insert);
$pad = 2;

$white=imagecolorallocate($insert,255,255,255);
$col=imagecolorallocate($insert,55,27,66);
imagefilltoborder ( $insert, 0, 0, $white,$white );
//write text
// top:
//imagettftext($insert, $size, $angle, $width/2-$bb_width/2, $bb_top+$pad, $col, $font, $text);
// left:
//imagettftext($insert, $size, $angle, $bb_left+$pad, $height/2-$bb_height/2, $col, $font, $text);
// bottom:
//imagettftext($insert, $size, $angle, $width/2-$bb_width/2, $height-$bb_height-$pad, $col, $font, $text);
// right:
imagettftext($insert, $size, $angle, $width-$bb_width-$pad, 22, $col, $font, $text);
//output picture

imagepng($insert,"",100);
imagedestroy($insert);
exit; 
?>

Link to comment
https://forums.phpfreaks.com/topic/74816-changed-to-php5-now-script-doesnt-work/
Share on other sites

My gut feeling is that it's a problem with your hosting provider's libraries.  I recommend sending the error to them.

 

Then again, I know very little about the GD libraries .. I'm sure someone else is better placed to advise.

 

You might also want to try changing the "" in the imagepng() call to null, as that is what is specified in the documentation for imagepng():

 

imagepng($insert, null, 100);

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.