Renlok Posted December 15, 2007 Share Posted December 15, 2007 ive only done a few things before with GD so im pretty noobish with it. But i cant figure out why it just loads the URL but no image <?php //generates pets image header ("Content-type: image/jpeg"); include('includes/config.php'); $roeid = $_GET['id']; $query = mysql_query("SELECT t.image, r.wearing FROM roe r LEFT JOIN roetypes t ON ( r.type = t.id ) WHERE r.id = $roeid") or die(mysql_error()); $roeinfo = mysql_fetch_array($query); $baseimg = $roeinfo['image']; //pet image $system=explode('.',$baseimg); if (preg_match('/jpg|jpeg/',$system[1])){ $background = imagecreatefromjpeg("images/pets/$baseimg"); } if (preg_match('/png/',$system[1])){ $background = imagecreatefrompng("images/pets/$baseimg"); } //loop though items of clothing $itemlist = explode(":", $roeinfo['wearing']); $list = "0"; for($y = 0; $y < count($itemlist); $y++){ $list .= ",".$itemlist[$y]; } //get clothing $sql = "SELECT image FROM roeclothes WHERE id IN ($list)"; $query = mysql_query($sql) or die(mysql_error()); while($array = mysql_fetch_array($query)){ //create the loop $clotheimg = $array['image']; $insert = imagecreatefromjpeg("images/clothes/clothes/$clotheimg"); imagecolortransparent($insert,imagecolorat($insert,0,0)); // Get overlay image width and hight for later use $insert_x = imagesx($insert); $insert_y = imagesy($insert); imagecopymerge($background,$insert,0,0,0,0,$insert_x,$insert_y,100); //overlay the clothing to the current image } //end the loop // Output the results as a png image, to be sent to viewer's // browser. The results can be displayed within an HTML document // as an image tag or background image for the document, tables, // or anywhere an image URL may be acceptable. imagejpeg($background,NULL,100); imagedestroy($background); //clean up the image ?> Quote Link to comment Share on other sites More sharing options...
Barand Posted December 15, 2007 Share Posted December 15, 2007 start by commenting out the header() call and running the script in your browser. See if there are any errors. Quote Link to comment Share on other sites More sharing options...
Renlok Posted December 15, 2007 Author Share Posted December 15, 2007 oh yeah im an idiot i never thought of that. also one last question is there a way to save an image generated like this so if you want to pull it up again you dont have to generate it each time. Quote Link to comment Share on other sites More sharing options...
Barand Posted December 15, 2007 Share Posted December 15, 2007 specify a filename in imagepng() or imagejpeg() Quote Link to comment Share on other sites More sharing options...
Renlok Posted December 15, 2007 Author Share Posted December 15, 2007 oh, ok thanks thats all i needed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.