Jump to content

Changed to PHP5 now script doesnt work


willpower

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);

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.