Jump to content

[SOLVED] GD image wont load


Renlok

Recommended Posts

Im pretty much a complete noob with GD. Im trying to make a script that will multiple images from a database over a base image. heres the script.

 

<?php
  //generates pets image
  header ("Content-type: image/jpeg"); 

$roeid = $_GET['id'];

$query = mysql_query("SELECT t.image 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'];
  //base image
  $system=explode('.',$baseimg);
if (preg_match('/jpg|jpeg/',$system[1])){
	$background = imagecreatefromjpeg("images/$baseimg"); 
}
if (preg_match('/png/',$system[1])){
	$background = imagecreatefrompng("images/$baseimg"); 
}
  //get clothing
  
  $sql = "SELECT c.image FROM roewearing w
	LEFT JOIN roeclothes c ON ( w.clothe = c.id )
	WHERE w.roeid = $roeid
	ORDER BY w.layer DESC";
  $query = mysql_query($sql) or die(mysql_error());

while($array = mysql_fetch_array($query)){ //create the loop

$clotheimg = $array['image'];
  $insert = imagecreatefromjpeg("images/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

  imagejpeg($background,"",100); 

//save the image
//createthumb($background,"images/roeimages/$roeid.png",200,200);

imagedestroy($background); //clean up the image
?>

Link to comment
https://forums.phpfreaks.com/topic/73513-solved-gd-image-wont-load/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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