Jump to content

[SOLVED] Problems with GD


Renlok

Recommended Posts

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
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.