PHP Version 5.1.6 versus PHP Version 4.3.10
The following code works ok in php 5.1.6 but doesnt return an image in
4.3.10.
put this code in the form where the image is being placed.
<img src="random.php?str=<?php echo $str; ?>" alt="capture image"
width="60" height="20" vspace="1" align="top" />
This is the random.php code
<?php
$str = $_GET['str'];
$imgX = 60;
$imgY = 20;
$image = imagecreatetruecolor(60, 20);
$backgr_col = imagecolorallocate($image, 238,239,239);
$border_col = imagecolorallocate($image, 208,208,208);
$text_col = imagecolorallocate($image, 46,60,31);
imagefilledrectangle($image, 0, 0, 60, 20, $backgr_col);
imagerectangle($image, 0, 0, 59, 19, $border_col);
$font = "VeraSe.ttf";
$font_size = 11;
$angle = 5;
$box = imagettfbbox($font_size, $angle, $font, $str);
$x = (int)($imgX - $box[4]) / 2;
$y = (int)($imgY - $box[5]) / 2;
imagettftext($image, $font_size, $angle, $x, $y, $text_col, $font, $str);
header("Content-type: image/png");
imagepng($image);
imagedestroy ($image);
?>
Is there something I have to do to so that the imaged is returned when
using 4.3.10. The isp who is hosting the website is using this version
so I have to adapt to suit.
Please can someone help I have spent hours trying to work round this.
Thanks
bill
Re: PHP Version 5.1.6 versus PHP Version 4.3.10
bill wrote:
> The following code works ok in php 5.1.6 but doesnt return an image in
> 4.3.10.
> put this code in the form where the image is being placed.
> <img src="random.php?str=<?php echo $str; ?>" alt="capture image"
> width="60" height="20" vspace="1" align="top" />
>
> This is the random.php code
>
> <?php
> $str = $_GET['str'];
>
> $imgX = 60;
> $imgY = 20;
> $image = imagecreatetruecolor(60, 20);
>
> $backgr_col = imagecolorallocate($image, 238,239,239);
> $border_col = imagecolorallocate($image, 208,208,208);
> $text_col = imagecolorallocate($image, 46,60,31);
>
> imagefilledrectangle($image, 0, 0, 60, 20, $backgr_col);
> imagerectangle($image, 0, 0, 59, 19, $border_col);
>
> $font = "VeraSe.ttf";
> $font_size = 11;
> $angle = 5;
> $box = imagettfbbox($font_size, $angle, $font, $str);
> $x = (int)($imgX - $box[4]) / 2;
> $y = (int)($imgY - $box[5]) / 2;
> imagettftext($image, $font_size, $angle, $x, $y, $text_col, $font, $str);
>
> header("Content-type: image/png");
> imagepng($image);
> imagedestroy ($image);
>
> ?>
> Is there something I have to do to so that the imaged is returned when
> using 4.3.10. The isp who is hosting the website is using this version
> so I have to adapt to suit.
> Please can someone help I have spent hours trying to work round this.
> Thanks
> bill
Sorry got it working. The font was causing the problem.
Thanks for looking
bill