I am having a problem creating images. I wish to create these header images on the fly, but sometimes the page will finish and only some of the will display. Yet, if I right-click the image in the browser, and select show picture, they are displayed.
Any suggestions?? Below is the code i use to generate the image.
<------->
error_reporting(E_NOTICE); // added trying to figure this out
if ($image) {
$imgfile=urldecode($image);
$label=urldecode($label);
if (is_file($imgfile)) {
/
Get Size of input file and declare/assign variables for them
/
$sizearray = GetImageSize($imgfile);
$src_width = $sizearray[0];
$src_height = $sizearray[1];
/ Create our temporary image in porportion to the original
Create 2 times as large as $imgfile to allow for better results with TTF (true type font)
/
$image_temp = ImageCreateTrueColor ($src_width2,$src_height2);
/
Allocate our colors of course
/
$black = ImageColorAllocate($image_temp,0,0,0);
$white = ImageColorAllocate($image_temp,255,255,255);
/
Fill our background with white for transparency
/
ImageFill($image_temp,0,0,$white);
/
Render the text onto the image:
/
ImageTTFText($image_temp,20,0,42,30,$black,realpath("tahoma.ttf"),$label ."\r");
/
Create an image to resize the text/transparency layer to
/
$img_resampled = ImageCreateTrueColor($src_width,$src_height);
/
Set the transparency
/
ImageColorTransparent($img_resampled,$white);
/
Resize the text/transparency image ($image_temp)
/
ImageCopyResampled($img_resampled,$image_temp,0,0,0,0,$src_width,$src_height,ImageSX($image_temp),ImageSY($image_temp));
ImageDestroy($image_temp);
/
Create our final canvas from the background file provided
/
$image_final = ImageCreateFromJPEG($imgfile);
/
Merge the layers
/
ImageCopyMerge($image_final,$img_resampled,0,0,0,0,$src_width,$src_height,70);//,ImageSX($image_temp),ImageSY($image_temp));
ImageInterlace($image_final,1);
/
send our header and image to the browser
/
header("Content: image/png");
ImagePNG($image_final);
ImageDestroy($image_final);
ImageDestroy($image_resampled);
} else {
header("Content: text/html");
die ("Image File not found ($image)");
}
} else {
die ("Syntax: createimage.php?\$imagestr&\$label");
}