Det ser umiddelbart ud til at det kan klare problemet for mig, relativt nemt! Og den kan jeg vist bruge til alle parametre.
Men jeg har dog et lille problem... Når jeg kører
http://localhost/gulv/img.php?page=sw&room=office&floor=asknaturhvidmat&wall=hvid&envi=couch i browseren, så får jeg blot en blank side, og med <img src="mit_billede.php" alt="" id="mit_billede"> får jeg det velkendte røde kryds, men billedet bliver genereret! Er der noget jeg har kikset et sted? Nedenunder kommer der lige en smørre med min generator:
### GENERATOR ###
<?php
class ImageGenerator extends Main {
var $width;
var $height;
var $quality = 100;
var $fileName = "";
/*******************************************************************************
* This is the imagebuilder function that builds the image
* based on different userselections
*
* $fullFileName | The filename of the image with entire path
* $theRoom | The selected room.
* $theFloor | The selected floor
* $theWall | The selected wallpaper
* $theEnvi | The selected furnitures
* $theLang | The language from $_GET
* $theXSize | The width of the final image
* $theYSize | The height of the final image
* $fullSize | Bool value - If the generated image is fullsize or not
* - true or false - true is the fullsize image in new window
*******************************************************************************/
function imageBuilder($theRoom, $theFloor, $theWall, $theEnvi, $theLang, $theXSize, $theYSize, $fullSize) {
$quality = 100; //Final image quality
$theW = $theXSize; //The width of final image
$theH = $theYSize; //The height of final image
/*** Beginning of language variabels ***/
$dateLabel = Main::langLabels($theLang, "date") .": ";
$roomLabel = Main::langLabels($theLang, "room") .": ";
/*** The path of the selected room ***/
$thePath = "rooms/".$theRoom."";
/*** The filename of the generated image ***/
if($fullSize == true) {
$theImageFileName = "generatedImages/room-". $theRoom ."_floor-". $theFloor ."_wall-". $theWall ."_envi-". $theEnvi ."_".$theLang."-full.jpg";
} else {
$theImageFileName = "generatedImages/room-". $theRoom ."_floor-". $theFloor ."_wall-". $theWall ."_envi-". $theEnvi ."_".$theLang.".jpg";
}
/*** Check if the default background exists ***/
if(file_exists($thePath."/bg.png")) {
$theBackgroundImage = imagecreatefrompng($thePath."/bg.png");
$theSourceImagesXSize = imagesx($theBackgroundImage);
$theSourceImagesYSize = imagesy($theBackgroundImage);
}
/*******************************************************
* Here the selected floor are placed onto the image
********************************************************/
$theFloor = $theFloor;
if (file_exists($thePath."/floors/".$theFloor.".png")) {
$createFromThis = $thePath."/floors/".$theFloor.".png";
} else {
$createFromThis = $thePath."/blank.png";
}
$theFloorImage = imagecreatefrompng($createFromThis);
imagecopy($theBackgroundImage,$theFloorImage,0,0,0,0,$theSourceImagesXSize,$theSourceImagesYSize);
imagejpeg($theFloorImage, $theImageFileName, $quality);
imagedestroy($theFloorImage);
/*******************************************************
* Here the selected wallpaper are placed onto the image
********************************************************/
$theWall = $theWall;
if (file_exists($thePath."/walls/".$theWall.".png")) {
$createFromThis = $thePath."/walls/".$theWall.".png";
} else {
$createFromThis = $thePath."/walls/blank.png";
}
$theWallImage = imagecreatefrompng($createFromThis);
imagecopy($theBackgroundImage,$theWallImage,0,0,0,0,$theSourceImagesXSize,$theSourceImagesYSize);
imagedestroy($theWallImage);
/*******************************************************
* Here the selected furnitures are placed onto the image
********************************************************/
$theEnvi = $theEnvi;
if (file_exists($thePath."/furnitures/".$theEnvi.".png")) {
$createFromThis = $thePath."/furnitures/".$theEnvi.".png";
} else {
$createFromThis = $thePath."/furnitures/blank.png";
}
$theEnviImage = imagecreatefrompng($createFromThis);
imagecopy($theBackgroundImage,$theEnviImage,0,0,0,0,$theSourceImagesXSize,$theSourceImagesYSize);
imagedestroy($theEnviImage);
/*******************************************************
* Here the logo are printed onto the image
*
* $theLogo | The path of the logo
* $theLogoX | Finds the width of the logo
* $theLogoY | Finds the height of the logo
********************************************************/
$theLogo = imagecreatefrompng("logo_trans.png");
$theLogoX = imagesx($theLogo);
$theLogoY = imagesy($theLogo);
imagecopy($theBackgroundImage,$theLogo,10,10,0,0,$theLogoX,$theLogoY);
imagedestroy($theLogo);
/*******************************************************
* At this stage in the image creation a box is
* generated and placed at the bottom of the image.
* In that box the date are written in the right side
* In the left side the different selections are written
********************************************************/
$selectionTxt = Main::langLabels($theLang, "room").": ". Main::langLabels($theLang, $theRoom) ." | ". Main::langLabels($theLang, "wall").": ". $theWall ." | ". Main::langLabels($theLang, "environment").": ". $theEnvi;
$dateTxt = Main::langLabels($theLang, "date").": ". date("d-m-Y");
imagefilledrectangle($theBackgroundImage, 0, 940, 1280, 960, imagecolorallocatealpha($theBackgroundImage, 0,0,0, 60));
imagettftext($theBackgroundImage, 8, 0, 1172, 953, imagecolorallocate($theBackgroundImage, 209,198, 140), "verdana.ttf", $dateTxt);
imagettftext($theBackgroundImage, 8, 0, 20, 953, imagecolorallocate($theBackgroundImage, 209,198, 140), "verdana.ttf", $selectionTxt);
/*******************************************************
* Here the final image is generated based on
* width and height defined in top of this script
*
* $theDestionationImage | The final image
* $theBackgroundImage | The total images with all
* the layers combined
********************************************************/
$theDestinationImage = imagecreatetruecolor($theW,$theH);
imagecopyresampled($theDestinationImage,$theBackgroundImage,0,0,0,0,$theW,$theH,$theSourceImagesXSize,$theSourceImagesYSize);
imagealphablending($theDestinationImage, true);
/*******************************************************
* Output the final image and clear the memory
********************************************************/
imagejpeg($theDestinationImage, $theImageFileName, $quality);
imagedestroy($theDestinationImage);
return;
}
}
?>